#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int,int> PII;

int main(void){
  vector<PII> v;
  int n;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int f,s;
    cin >> f >> s;
    v.push_back(make_pair(f,s));
  }
  sort(v.begin(), v.end());
  for (int i=0; i<n; i++){
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}
