#include <bits/stdc++.h>
using namespace std;
int n, cnt = 1, d[222], s[222];
struct node {
  int l, r, id;
} p[222];
bool check(int i) {
  int l = s[i], r = s[i] + d[i] - 1;
  bool flag = true;
  for (int i = 1; i < cnt; ++i) {
    if (p[i].l > r || p[i].r < l)
      continue;
    else {
      flag = false;
      break;
    }
  }
  return flag;
}
bool cmp1(node a, node b) { return a.l < b.l; }
bool cmp2(node a, node b) { return a.id < b.id; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d %d", &s[i], &d[i]);
  p[0].l = 0;
  p[0].r = 0;
  p[0].id = 0;
  for (int i = 1; i <= n; ++i) {
    if (check(i)) {
      p[cnt].l = s[i];
      p[cnt].r = s[i] + d[i] - 1;
      p[cnt].id = i;
      cnt++;
    } else {
      sort(p, p + cnt, cmp1);
      int j;
      bool flag = false;
      for (j = 1; j < cnt; ++j) {
        if (p[j].l - p[j - 1].r - 1 >= d[i]) {
          flag = true;
          p[cnt].l = p[j - 1].r + 1;
          p[cnt].r = p[cnt].l + d[i] - 1;
          p[cnt].id = i;
          cnt++;
          break;
        }
      }
      if (!flag) {
        p[cnt].l = p[cnt - 1].r + 1;
        p[cnt].r = p[cnt].l + d[i] - 1;
        p[cnt].id = i;
        cnt++;
      }
    }
  }
  sort(p, p + cnt, cmp2);
  for (int i = 1; i < cnt; ++i) printf("%d %d\n", p[i].l, p[i].r);
  return 0;
}
