#include <bits/stdc++.h>
using namespace std;
struct Node {
  int x, y, next;
};
Node sq[1000];
int n, s[1000], t[1000], cnt;
bool inser(int id) {
  int st = s[id], en = s[id] + t[id] - 1;
  bool flag = false;
  for (int i = 0; i != -1; i = sq[i].next) {
    if (st > sq[i].y) {
      if (sq[i].next == -1) {
        sq[i].next = id + 1;
        sq[id + 1].x = st, sq[id + 1].y = en;
        return true;
      } else if (sq[sq[i].next].x > en) {
        sq[id + 1].x = st, sq[id + 1].y = en;
        sq[id + 1].next = sq[i].next;
        sq[i].next = id + 1;
        return true;
      }
    } else
      break;
  }
  for (int i = 0; i != -1; i = sq[i].next) {
    st = sq[i].y + 1, en = st + t[id] - 1;
    if (st > sq[i].y) {
      if (sq[i].next == -1) {
        sq[i].next = id + 1;
        sq[id + 1].x = st, sq[id + 1].y = en;
        return true;
      } else if (sq[sq[i].next].x > en) {
        sq[id + 1].x = st, sq[id + 1].y = en;
        sq[id + 1].next = sq[i].next;
        sq[i].next = id + 1;
        return true;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d %d", &s[i], &t[i]);
  memset(sq, -1, sizeof sq);
  sq[0].x = 0, sq[0].y = 0;
  for (int i = 0; i < n; i++) inser(i);
  for (int i = 1; i <= n; i++) printf("%d %d\n", sq[i].x, sq[i].y);
}
