#include <bits/stdc++.h>
using namespace std;
int n, s[300], d[300], a[300], b[300], q, z, bb[300];
int main() {
  int i, j, k, bj;
  b[0] = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i] >> d[i];
    bj = 1;
    q = s[i];
    z = s[i] + d[i] - 1;
    for (j = 1; j < i; j++)
      if (!(z < a[j] || q > b[j])) {
        bj = 0;
        break;
      }
    if (i == 1 || bj == 1) {
      a[i] = q;
      b[i] = z;
      cout << a[i] << ' ' << b[i] << endl;
      bb[i] = z;
      sort(bb + 1, bb + 1 + i);
      continue;
    }
    for (j = 0; j < i; j++) {
      q = bb[j] + 1;
      z = bb[j] + d[i];
      if (a[i] != 0 && a[i] < q) continue;
      bj = 1;
      for (k = 1; k < i; k++)
        if (!(q > b[k] || z < a[k])) {
          bj = 0;
          break;
        }
      if (bj == 1) {
        a[i] = q;
        b[i] = z;
        bb[i] = z;
        sort(bb + 1, bb + 1 + i);
      }
    }
    cout << a[i] << ' ' << b[i] << endl;
  }
  return 0;
}
