#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

// sorting pairs

struct Point{
  int x;
  int y;

  bool operator<(const Point& another) const{
    if(x < another.x){
      return true;
    }
    if(x == another.x){
      if(y < another.y){
        return true;
      }
    }

    return false;
    
  }
  
};

int main(){
  long ii,jj,kk;
  vector<int> ret;
  int n;
  vector<Point> p;

  cin >> n;

  p.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> p[ii].x >> p[ii].y;
  }
  
  sort(p.begin(),p.end());
  
  for(ii=0;ii<n;ii++){
    cout << p[ii].x << " " << p[ii].y << endl;
  }
  
  return 0;

}

