#include <bits/stdc++.h>
using namespace std;

bool operator<(pair<int, int> a, pair<int, int> b) {
    if (a.first < b.first) return true;
    else if (a.first > b.first) return false;
    else if (a.second <= b.second) return true;
    else return false;
}

int main(void) {
    vector<pair<int, int> > ve;
    int n, i, x, y;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d %d", &x, &y);
        ve.push_back(make_pair(x, y));
    }
    sort(ve.begin(), ve.end());
    for (i = 0; i < ve.size(); i++) {
        printf("%d %d\n", ve[i].first, ve[i].second);
    }
}
