#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e3 + 10;
int n, m, k;
struct oh {
  int r, l;
  oh *next;
} *org = new oh, *ed = new oh;
oh *sert(int l, int d);
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  org->r = org->l = 0;
  ed->r = ed->l = 0x7fffffff;
  org->next = ed;
  while (n--) {
    int w, d;
    cin >> w >> d;
    oh x = *sert(w, d);
    cout << x.l << " " << x.r << endl;
  }
  return 0;
}
oh *sert(int l, int d) {
  int r = l + d - 1;
  oh *q = new oh, *p1 = org, *p2, *fl = 0;
  while (p1 != ed) {
    p2 = p1->next;
    if (fl == 0 && p2->l > p1->r + d) {
      fl = p1;
      q->l = p1->r + 1;
      q->r = q->l + d - 1;
    }
    if (l > p1->r && r < p2->l) {
      fl = p1;
      q->l = l;
      q->r = r;
      break;
    }
    p1 = p2;
  }
  q->next = fl->next;
  fl->next = q;
  return q;
}
