#include <bits/stdc++.h>
using namespace std;
vector<set<int> > line(200002);
void addnum(int heavy, int num) {
  set<int>::iterator itr = line[heavy].find(num);
  if (itr == line[heavy].end()) {
    line[heavy].insert(num);
  } else {
    line[heavy].erase(num);
    line[heavy].insert(num + 1);
  }
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    addnum(a, b);
  }
  for (int i = 0; i < 200002; ++i) {
    for (set<int>::iterator itr = line[i].begin(); itr != line[i].end();
         ++itr) {
      if (*itr == 0) {
        cout << i << " " << 0 << endl;
      } else {
        addnum(i + 1, *itr - 1);
      }
    }
  }
  return 0;
}
