// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/5/ITP2_5_A
// https://dai1741.github.io/maximum-algo-2012/docs/cpp-sort/

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::pair<int, int>> pairs(n);
    for (int i = 0; i < n; i++)
    {
        int x, y;
        std::cin >> x >> y;
        pairs[i] = std::make_pair(x, y);
    }

    std::sort(pairs.begin(), pairs.end());

    for (auto &x : pairs)
    {
        std::cout << x.first << " " << x.second << std::endl;
    }

    return 0;
}

