#P2772. Maximal Points

    ID: 16034 Type: Default 1000ms 256MiB

Maximal Points

Maximal Points

Given a set of n points in the plane, a point \((x,y)\) is said to dominate another point \((a,b)\) if and only if \(x \geq a\) and \(y \geq b\). In other words, the point \((a,b)\) lies in the infinite region having \((x,y)\) as its top‐right corner.

A point is considered a maximal point if it is not dominated by any other point in the set. Your task is to find all the maximal points among the given n points and output their coordinates in increasing order of the x-coordinate.

inputFormat

The first line of input contains an integer n representing the number of points. The next n lines each contain two integers separated by space, representing the coordinates \(x\) and \(y\) of each point.

outputFormat

Output the coordinates of all maximal points, one per line. Each line should contain two integers representing the x and y coordinates, separated by a space. The points must be printed in increasing order of the x-coordinate.

sample

5
1 2
2 1
3 3
2 2
1 3
3 3

</p>