#include <bits/stdc++.h>
using namespace std;
const long long int inf = 2000000000;
struct node {
  long long int l, r;
  bool operator<(const node &a) const { return l > a.l; }
};
long long int ans[205][2];
priority_queue<node> q;
priority_queue<node> p;
int main() {
  int n, i;
  long long int s, d;
  scanf("%d", &n);
  node f;
  f.l = 1;
  f.r = inf;
  q.push(f);
  for (i = 0; i < n; i++) {
    scanf("%I64d %I64d", &s, &d);
    bool flag = 0;
    while (!q.empty()) {
      node now = q.top();
      q.pop();
      if (now.l <= s && now.r >= s + d - 1) {
        node a, b;
        ans[i][0] = s, ans[i][1] = s + d - 1;
        a.l = now.l, a.r = s - 1;
        b.l = s + d, b.r = now.r;
        if (a.l <= a.r) q.push(a);
        if (b.l <= b.r) q.push(b);
        flag = 1;
        break;
      }
      p.push(now);
    }
    if (!flag) {
      while (!p.empty()) {
        node now = p.top();
        p.pop();
        if (now.r - now.l + 1 >= d) {
          node a;
          ans[i][0] = now.l, ans[i][1] = now.l + d - 1;
          a.l = now.l + d, a.r = now.r;
          if (a.l <= a.r) q.push(a);
          break;
        }
        q.push(now);
      }
    }
    while (!p.empty()) {
      node now = p.top();
      q.push(now);
      p.pop();
    }
  }
  for (i = 0; i < n; i++) printf("%I64d %I64d\n", ans[i][0], ans[i][1]);
}
