#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
bool cmp(pii p1,pii p2){
    if(p1.first!=p2.first) return p1.first<p2.first;
    else return p1.second<p2.second;
}
int main() {
    int n;
    cin>>n;
    vector<pii> v(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[i]={a,b};
    }
    sort(v.begin(),v.end(),cmp);
    for(int i=0;i<n;i++){
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}
