#include <bits/stdc++.h>
using namespace std;
const int maxn = 207;
const long long inf = 1LL << 55;
long long x[maxn], y[maxn];
struct node {
  long long ls, rs;
};
vector<node> p[maxn];
int Find(long long ls, long long rs, int s) {
  for (int i = 0; i < p[s].size(); i++) {
    node tmp = p[s][i];
    if (tmp.ls <= ls && rs <= tmp.rs) return i;
  }
  for (int i = 0; i < p[s].size(); i++) {
    node tmp = p[s][i];
    if (tmp.rs - tmp.ls >= rs - ls) return i;
  }
  return -1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
  p[0].push_back(node{1, inf});
  for (int i = 1; i <= n; i++) {
    int pos = Find(x[i], y[i] + x[i] - 1, i - 1);
    for (int j = 0; j < p[i - 1].size(); j++) {
      node tmp = p[i - 1][j];
      if (pos != j)
        p[i].push_back(tmp);
      else {
        if (tmp.ls <= x[i] && x[i] + y[i] - 1 <= tmp.rs) {
          cout << x[i] << " " << x[i] + y[i] - 1 << endl;
          if (tmp.ls <= x[i] - 1) p[i].push_back(node{tmp.ls, x[i] - 1});
          if (x[i] + y[i] <= tmp.rs) p[i].push_back(node{x[i] + y[i], tmp.rs});
        } else {
          cout << tmp.ls << " " << tmp.ls + y[i] - 1 << endl;
          tmp.ls += y[i];
          if (tmp.ls <= tmp.rs) p[i].push_back(tmp);
        }
      }
    }
  }
  return 0;
}
