import java.util.*;
class Point{
int x,y;
public Point(int x, int y){
this.x = x;
this.y = y;
}
}
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int x = 0, y = 0;
Point[] points = new Point[n];
for(int i = 0 ; i < n ; i++){
x = sc.nextInt();
points[i] = new Point(x, sc.nextInt());
}
Arrays.sort(points, new Comparator<Point>(){
public int compare(Point arg1, Point arg2) {
// TODO Auto-generated method stub
return arg2.x -arg1.x;
}
});
int maxY = -1;
for (int i = 0 ; i < n; i++){
if(points[i].y > maxY){
maxY= points[i].y;
System.out.println(points[i].x+" "+points[i].y);
}
}
}
}