#include <bits/stdc++.h>
using namespace std;
int find(vector<int> v, int k) {
  if (v.size() == 0) return -1;
  int l = 0, r = v.size() - 1;
  while (l < r - 1) {
    int mid = (l + r) / 2;
    if (v[mid] == k)
      return mid;
    else if (v[mid] < k)
      l = mid;
    else
      r = mid;
  }
  if (v[l] == k) return l;
  if (v[r] == k) return r;
  return -1;
}
int main() {
  int k;
  cin >> k;
  vector<int> v;
  for (int i = 0; i < k; i++) {
    int p, q;
    cin >> p >> q;
    p += q;
    while (true) {
      int t = find(v, p);
      if (t == -1) {
        v.push_back(p);
        goto heaven;
      } else {
        v.erase(v.begin() + t);
        p++;
      }
    }
  heaven:
    sort(v.begin(), v.end());
  }
  for (int i = 0; i < v.size(); i++) cout << v[i] << " 0\n";
  return 0;
}
