#include <bits/stdc++.h>
using namespace std;
const int MXN = (int)1e5 + 7;
long long a[MXN], b[MXN];
long long ans[MXN][2];
set<long long> buf;
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) scanf("%lld %lld", a + i, b + i);
  buf.insert(1);
  for (int i = 1; i < n + 1; i++) {
    long long ll = a[i], rr = a[i] + b[i] - 1;
    bool gg = 0;
    for (int j = 1; j < i; j++) {
      if (rr < ans[j][0] || ll > ans[j][1]) continue;
      gg = 1;
      break;
    }
    if (!gg) {
      ans[i][0] = ll, ans[i][1] = rr;
      buf.insert(rr + 1);
      continue;
    }
    for (long long st : buf) {
      ll = st;
      rr = st + b[i] - 1;
      bool gg = 0;
      for (int j = 1; j < i; j++) {
        if (rr < ans[j][0] || ll > ans[j][1]) continue;
        gg = 1;
        break;
      }
      if (!gg) {
        ans[i][0] = ll, ans[i][1] = rr;
        buf.insert(rr + 1);
        break;
      }
    }
  }
  for (int i = 1; i < n + 1; i++) printf("%lld %lld\n", ans[i][0], ans[i][1]);
  return 0;
}
