#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int st, end;
} ar[10000];
bool cmp(node a, node b) { return a.st < b.st; }
int main() {
  ar[0].st = 0;
  ar[0].end = 0;
  ar[1].st = 1e15;
  ar[1].end = 1e15;
  int n, t, cnt, i, j;
  bool f = 0;
  long long int st, end, a, b;
  cin >> n;
  cnt = 2;
  for (t = 1; t <= n; t++) {
    cin >> st >> end;
    if (t == 1) {
      cout << st << " " << st + end - 1 << endl;
      a = st;
      b = st + end - 1;
    } else {
      a = st;
      b = st + end - 1;
      f = 0;
      for (j = 1; j < cnt; j++) {
        if (a > ar[j - 1].end and b < ar[j].st) {
          f = 1;
          break;
        }
      }
      if (f == 1) {
        cout << a << " " << b << endl;
      } else
        for (i = 0; i < cnt; i++) {
          a = ar[i].end + 1;
          b = a + end - 1;
          f = 0;
          for (j = 1; j < cnt; j++) {
            if (a > ar[j - 1].end and b < ar[j].st) {
              f = 1;
              break;
            }
          }
          if (f) {
            cout << a << " " << b << endl;
            break;
          }
        }
    }
    ar[cnt].st = a;
    ar[cnt].end = b;
    cnt++;
    sort(ar, ar + cnt, cmp);
  }
  return 0;
}
