#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  int l[210], r[210];
  int l_tmp[210], r_tmp[210];
  int cnt = 0, tmp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    l[i] = a;
    r[i] = a + b - 1;
  }
  cout << l[0] << " " << r[0] << endl;
  int x = 1;
  if (x >= l[0] && x <= r[0]) x = r[0] + 1;
  for (int i = 1; i < n; i++) {
    x = 1;
    bool f = false;
    for (int j = 0; j < i; j++)
      if (l[i] > r[j] || r[i] < l[j]) {
      } else {
        f = true;
        break;
      }
    if (f) {
    back:
      for (int j = 0; j < i; j++) {
        if (x > r[j] || x + r[i] - l[i] < l[j]) {
        } else {
          x = r[j] + 1;
          goto back;
        }
      }
      r[i] = x + r[i] - l[i];
      l[i] = x;
    }
    cout << l[i] << " " << r[i] << endl;
  }
  return 0;
}
