#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int a, b;
    scanf(" %d %d", &a, &b);
    map<int, int>::iterator check = m.find(a + b);
    if (check == m.end()) {
      m[a + b] = 0;
    } else {
      m[a + b]++;
    }
  }
  bool flag = true;
  while (flag) {
    flag = false;
    for (map<int, int>::iterator itr = m.begin(); itr != m.end();) {
      if (itr->second != 0) {
        map<int, int>::iterator check = m.find(itr->first + itr->second);
        if (check == m.end()) {
          m[itr->first + itr->second] = 0;
        } else {
          m[itr->first + itr->second]++;
        }
        map<int, int>::iterator before = itr;
        itr++;
        m.erase(before);
        flag = true;
      } else {
        itr++;
      }
    }
  }
  for (map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++) {
    cout << itr->first << " " << itr->second << endl;
  }
  return 0;
}
