#include <bits/stdc++.h>
using namespace std;
struct DT {
  long long s, d;
  long long st, ed;
  long long id;
} data[300];
long long ans1[300], ans2[300];
bool cmp(DT a, DT b) { return a.st < b.st; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &data[i].s, &data[i].d);
    data[i].id = i;
  }
  data[0].st = 0;
  data[0].ed = 0;
  for (int i = 1; i <= n; i++) {
    bool flag = true;
    for (int j = 1; j < i; j++) {
      if (data[i].s >= data[j].st && data[i].s <= data[j].ed) flag = false;
      if (data[i].s + data[i].d - 1 >= data[j].st &&
          data[i].s + data[i].d - 1 <= data[j].ed)
        flag = false;
      if (data[i].s <= data[j].st && data[i].s + data[i].d - 1 >= data[j].ed)
        flag = false;
    }
    if (flag == true)
      data[i].st = data[i].s, data[i].ed = data[i].st + data[i].d - 1;
    else {
      sort(data, data + i, cmp);
      bool flag2 = false;
      for (int j = 1; j < i; j++) {
        int tst = data[j - 1].ed + 1;
        int ted = data[j].st;
        if (tst + data[i].d - 1 < ted) {
          data[i].st = tst;
          data[i].ed = tst + data[i].d - 1;
          break;
        }
        if (!flag2) {
          data[i].st = data[i - 1].ed + 1;
          data[i].ed = data[i].st + data[i].d - 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    ans1[data[i].id] = data[i].st, ans2[data[i].id] = data[i].ed;
  for (int i = 1; i <= n; i++) printf("%I64d %I64d\n", ans1[i], ans2[i]);
  return 0;
}
