#include <iostream>
#include <algorithm>
using namespace std;
typedef struct {
int x;
int y;
}Position;
bool cmp(const Position& p1, const Position& p2)
{
if (p1.x == p2.x) //좌표 x가 같다면
return p1.y < p2.y; //좌표 y기준으로 올림차순
else
return p1.x < p2.x; //좌표 x기준으로 올림차순
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
Position* arr = new Position[n];
for (int i = 0; i < n; i++)
cin >> arr[i].x >> arr[i].y;
sort(arr, arr + n, cmp);
for (int i = 0; i < n; i++)
cout << arr[i].x << " " << arr[i].y << "\n";
delete[] arr;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgc3RydWN0IHsKCWludCB4OwoJaW50IHk7Cn1Qb3NpdGlvbjsKCmJvb2wgY21wKGNvbnN0IFBvc2l0aW9uJiBwMSwgY29uc3QgUG9zaXRpb24mIHAyKQp7CglpZiAocDEueCA9PSBwMi54KQkJCS8v7KKM7ZGcIHjqsIAg6rCZ64uk66m0CgkJcmV0dXJuIHAxLnkgPCBwMi55OwkJLy/sooztkZwgeeq4sOykgOycvOuhnCDsmKzrprzssKjsiJwKCWVsc2UKCQlyZXR1cm4gcDEueCA8IHAyLng7CQkvL+yijO2RnCB46riw7KSA7Jy866GcIOyYrOumvOywqOyInAp9CgppbnQgbWFpbih2b2lkKQp7Cglpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CgljaW4udGllKE5VTEwpOwoKCWludCBuOwoJY2luID4+IG47CglQb3NpdGlvbiogYXJyID0gbmV3IFBvc2l0aW9uW25dOwoKCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQoJCWNpbiA+PiBhcnJbaV0ueCA+PiBhcnJbaV0ueTsKCglzb3J0KGFyciwgYXJyICsgbiwgY21wKTsKCglmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykKCQljb3V0IDw8IGFycltpXS54IDw8ICIgIiA8PCBhcnJbaV0ueSA8PCAiXG4iOwoKCWRlbGV0ZVtdIGFycjsKCXJldHVybiAwOwp9