#include <iostream>
#include<utility>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n,x,y;
    cin >> n;
    vector< pair<int, int> > vec(n);
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        vec[i].first = x;
        vec[i].second = y;
    }
    sort(begin(vec), end(vec));
    for (int i = 0; i < n; i++) {
        cout << vec[i].first << " ";
        cout << vec[i].second << endl;
    }
}

