#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9 + 7;
const int maxn = 205;
const int inf = 0x3f3f3f3f;
int m, n, st[maxn], ed[maxn];
int main() {
  while (scanf("%d", &n) != EOF) {
    int s, d, t;
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &s, &t);
      d = s + t - 1;
      bool f = 0;
      for (int j = 1; j < i; j++) {
        if (d < st[j] || s > ed[j]) continue;
        f = 1;
      }
      if (!f) {
        st[i] = s, ed[i] = d;
        printf("%d %d\n", s, d);
        continue;
      }
      int ans_s = inf;
      for (int j = 0; j < i; j++) {
        if (j == 0)
          s = 1;
        else
          s = ed[j] + 1;
        d = s + t - 1;
        int f2 = 0;
        for (int k = 1; k < i; k++) {
          if (d < st[k] || s > ed[k]) continue;
          f2 = 1;
        }
        if (f2) continue;
        ans_s = min(s, ans_s);
      }
      st[i] = ans_s, ed[i] = ans_s + t - 1;
      printf("%d %d\n", ans_s, ans_s + t - 1);
    }
  }
  return 0;
}
