#t374. 寻找极大点

寻找极大点

Maximal Points

Problem Description

On a plane, consider two points (x,y)(x,y) and (a,b)(a,b). We say that (x,y)(x,y) dominates (a,b)(a,b) if x≥ax \ge a and y≥by \ge b.

Graphically, this means that (a,b)(a,b) lies in the infinite region whose upper-right corner is (x,y)(x,y).

Given a set of nn points, there always exist some points that are not dominated by any point in the set; these are called the maximal points.

Write a program to find all maximal points and output their coordinates in increasing order of the xx-coordinate.

This problem guarantees: n≤100n \le 100, and no point has a negative coordinate.

Input Format

The input consists of two lines.

The first line is a positive integer nn, the number of points.

The second line contains the coordinates of the nn points. All coordinate values are integers in the range 00 to 100100, and no two points in the input have the same coordinates.

Output Format

Output all maximal points in increasing order of the xx-coordinate.

The output format is: (x1,y1),(x2,y2),...(xk,yk)(x_1,y_1),(x_2,y_2),...(x_k,y_k).

Note: consecutive points are separated by a ,, and there is no , after the last point. Outputting too few or too many points will be judged wrong.

Sample Input 1

5 
1 2 2 2 3 1 2 3 1 4

Sample Output 1

(1,4),(2,3),(3,1)

Hint

Constraints

1s, 1024KiB for each test case.