#C6470. Smallest Enclosing Rectangle for Rare Plants

    ID: 50234 Type: Default 1000ms 256MiB

Smallest Enclosing Rectangle for Rare Plants

Smallest Enclosing Rectangle for Rare Plants

You are given a square garden of side length L and M rare flowering plants placed at specific positions. Your task is to determine the dimensions of the smallest axis-aligned rectangle that can enclose all the rare plants.

The rectangle's dimensions are determined by the formula:

$$\text{height} = \max(x) - \min(x) + 1$$

$$\text{width} = \max(y) - \min(y) + 1$$

where \(x\) and \(y\) represent the row and column indices respectively. The input is provided from the standard input (stdin) and the result must be printed to the standard output (stdout).

inputFormat

The first line of input contains two integers L and M, where L is the side length of the square garden and M is the number of rare flowering plants.

The next M lines each contain two integers representing the row and column positions of a plant.

Note: All positions are 1-indexed.

outputFormat

Output two integers separated by a space: the height and the width of the smallest rectangle that can encapsulate all the rare plants.

## sample
5 3
1 2
3 3
4 1
4 3