package Undone;
import java.util.*;
class mydata implements Comparable<mydata>{
int x;
int y;
mydata(int x2,int y2){
this.x=x2;
this.y=y2;
}
@Override
public int compareTo(mydata o) {
// TODO Auto-generated method stub
if(this.x==o.x)
{
return this.y-o.y;
}
return this.x-o.x;
}
@Override
public String toString() {
return x+" "+y;
}
}
public class a915 {
//a915: 二维点排序
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
List<mydata> data=new ArrayList();
int num=sc.nextInt();
for(int i=0;i<num;i++)
{
int x=sc.nextInt();
int y=sc.nextInt();
data.add(new mydata(x,y));
}
Collections.sort(data);
for(int i=0;i<data.size();i++)
{
System.out.println(data.get(i));
}
}
}