#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Point {
int x, y;
};
bool bigyo(const Point& a, const Point& b) {
if (a.x == b.x)
return a.y < b.y;
return a.x < b.x;
}
int main() {
int N;
scanf("%d", &N);
vector<Point> points(N);
for (int i = 0; i < N; ++i) {
cin >> points[i].x >> points[i].y;
}
sort(points.begin(), points.end(), bigyo);
for (const auto& point : points) {
printf("%d %d\n", point.x, point.y);
}
return 0;
}