#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int, int> pii;
const int N = 110;
pii stu[N];
int n;
int main()
{
cin >> n;
for(int i = 0; i < n; i ++) cin >> stu[i].y >> stu[i].x;
sort(stu, stu + n); //sort对pair排序,先按first排序,first相同时按second排序
for(int i = 0; i < n; i ++) cout << stu[i].y << ' ' << stu[i].x << endl;
return 0;
}