#include <bits/stdc++.h>
using namespace std;
const int N = 200 + 10;
const int INF = 0x3f3f3f3f;
struct Node {
  int l, r;
} a[N], now;
bool pan(Node a, Node b) {
  if (a.l > b.r || a.r < b.l) return true;
  return false;
}
bool cmp(Node a, Node b) { return a.l < b.l; }
int main() {
  int n;
  scanf("%d", &n);
  int i, j;
  for (i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (i == 0) {
      a[i].l = x;
      a[i].r = x + y - 1;
      printf("%d %d\n", a[i].l, a[i].r);
    } else {
      now.l = x;
      now.r = x + y - 1;
      sort(a, a + i, cmp);
      for (j = 0; j < i; j++) {
        if (!pan(now, a[j])) break;
      }
      if (j == i) {
        a[i] = now;
        printf("%d %d\n", a[i].l, a[i].r);
        continue;
      }
      now.l = 1;
      now.r = y;
      for (j = 0; j < i; j++) {
        if (pan(now, a[j])) {
          a[i] = now;
          printf("%d %d\n", a[i].l, a[i].r);
          break;
        } else {
          now.l = a[j].r + 1;
          now.r = a[j].r + y;
        }
      }
      if (j == i) {
        a[i] = now;
        printf("%d %d\n", a[i].l, a[i].r);
      }
    }
  }
  return 0;
}
