#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
pair<int,int>p[1<<17];
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>p[i].first>>p[i].second;
    sort(p,p+n);
    for(int i=0;i<n;i++)cout<<p[i].first<<" "<<p[i].second<<endl;
}
