#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const double pi = acos(-1.0);
const int maxn = 300005;
long long b, e, x, y, z, ans, i, j, k, l, n, m;
struct app {
  long long b, e;
};
app a[500];
int cmp(app a, app b) {
  return a.b < b.b;
  return a.e < b.e;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    if (i == 1) {
      cout << x << " " << x + y - 1 << endl;
      a[++k].b = x;
      a[k].e = x + y - 1;
    } else {
      bool f = 1;
      for (int j = 1; j <= k; j++)
        if (!(a[j].e < x || x + y - 1 < a[j].b)) {
          f = 0;
          break;
        }
      if (f) {
        cout << x << " " << x + y - 1 << endl;
        a[++k].b = x;
        a[k].e = x + y - 1;
      } else {
        b = 1;
        e = b + y - 1;
        for (int j = 1; j <= k; j++) {
          if (!(e < a[j].b || b > a[j].e)) {
            b = a[j].e + 1;
            e = b + y - 1;
          } else
            break;
        }
        x = b;
        cout << x << " " << x + y - 1 << endl;
        a[++k].b = x;
        a[k].e = x + y - 1;
      }
    }
    sort(a + 1, a + k + 1, cmp);
  }
}
