#include <bits/stdc++.h>
using namespace std;
const int maxn = 50000 + 100;
struct node {
  int a, b;
};
bool operator<(node a, node b) { return a.a < b.a; }
int main() {
  int n;
  cin >> n;
  map<node, int> ans;
  bool flag = 0;
  node a = {0, 0};
  ans.insert(make_pair(a, 0));
  int ta, tb;
  cin >> ta >> tb;
  a = {ta, ta + tb - 1};
  map<node, int>::iterator it, itor;
  ans.insert(make_pair(a, 1));
  cout << a.a << " " << a.b << endl;
  for (int i = 2; i <= n; ++i) {
    int a, b;
    cin >> a >> b;
    int tmp = b;
    b = b + a - 1;
    node c = {a, b};
    flag = 0;
    it = ans.begin();
    it++;
    for (; it != ans.end(); ++it) {
      it--;
      itor = it;
      it++;
      if (it->first.a > b && itor->first.b < a) {
        flag = 1;
        break;
      }
    }
    it--;
    if (flag || it->first.b < a) {
      ans.insert(make_pair(c, i));
      cout << c.a << " " << c.b << endl;
    } else {
      flag = 0;
      it = ans.begin();
      it++;
      for (; it != ans.end(); ++it) {
        it--;
        itor = it;
        it++;
        if (it->first.a - itor->first.b > tmp) {
          break;
        }
      }
      if (it != ans.end()) {
        node c = {itor->first.b + 1, itor->first.b + tmp};
        ans.insert(make_pair(c, i));
        cout << c.a << " " << c.b << endl;
      } else {
        it--;
        node c = {it->first.b + 1, it->first.b + tmp};
        ans.insert(make_pair(c, i));
        cout << c.a << " " << c.b << endl;
      }
    }
  }
  return 0;
}
