#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    a[i] = x + y;
  }
  sort(a.begin(), a.end());
  while (!a.empty()) {
    if (a.size() != 1)
      if (a[1] == a[0]) {
        a[1]++;
        a.erase(a.begin());
      } else {
        cout << a[0] << " " << 0 << endl;
        a.erase(a.begin());
      }
    else {
      cout << a[0] << " 0" << endl;
      a.erase(a.begin());
    }
  }
  return 0;
}
