#include <iostream>
#include <algorithm>
using namespace std;
typedef struct _Position {
int x;
int y;
}Position;
bool cmp(const Position& p1, const Position& p2)
{
if (p1.y == p2.y) //좌표 y가 같다면
return p1.x < p2.x; //좌표 x를 기준으로 올림차순
else
return p1.y < p2.y; //좌표 y를 기준으로 올림차순
}
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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgc3RydWN0IF9Qb3NpdGlvbiB7CglpbnQgeDsKCWludCB5Owp9UG9zaXRpb247Cgpib29sIGNtcChjb25zdCBQb3NpdGlvbiYgcDEsIGNvbnN0IFBvc2l0aW9uJiBwMikKewoJaWYgKHAxLnkgPT0gcDIueSkJCQkvL+yijO2RnCB56rCAIOqwmeuLpOuptAoJCXJldHVybiBwMS54IDwgcDIueDsJCS8v7KKM7ZGcIHjrpbwg6riw7KSA7Jy866GcIOyYrOumvOywqOyInAoJZWxzZQoJCXJldHVybiBwMS55IDwgcDIueTsJCS8v7KKM7ZGcIHnrpbwg6riw7KSA7Jy866GcIOyYrOumvOywqOyInAp9CgppbnQgbWFpbih2b2lkKQp7Cglpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CgljaW4udGllKE5VTEwpOwoKCWludCBuOwoJY2luID4+IG47CglQb3NpdGlvbiogIGFyciA9IG5ldyBQb3NpdGlvbltuXTsKCglmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykKCQljaW4gPj4gYXJyW2ldLnggPj4gYXJyW2ldLnk7CgoJc29ydChhcnIsIGFyciArIG4sIGNtcCk7CgoJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgkJY291dCA8PCBhcnJbaV0ueCA8PCAiICIgPDwgYXJyW2ldLnkgPDwgIlxuIjsKCglkZWxldGVbXSBhcnI7CglyZXR1cm4gMDsKfQ==