#include <bits/stdc++.h>
using namespace std;
int n;
int s[220];
int d[220];
int sol[220];
vector<pair<int, int> > v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n;
  for (int(i) = (0); (i) < (n); (i)++) cin >> s[i] >> d[i];
  for (int(i) = (0); (i) < (n); (i)++) {
    int last = 1;
    int ok = 0;
    for (typeof(v.begin()) it = (v.begin()); it != v.end(); it++) {
      if (last <= s[i] && it->first >= s[i] + d[i]) {
        v.insert(it, make_pair((s[i]), (d[i])));
        ok = 1;
        sol[i] = s[i];
        break;
      }
      last = it->first + it->second;
    }
    if (v.empty() ||
        v[((int)v.size()) - 1].first + v[((int)v.size()) - 1].second <= s[i]) {
      v.push_back(make_pair((s[i]), (d[i])));
      ok = 1;
      sol[i] = s[i];
    }
    if (!ok) {
      last = 1;
      for (typeof(v.begin()) it = (v.begin()); it != v.end(); it++) {
        if (it->first >= last + d[i]) {
          v.insert(it, make_pair((last), (d[i])));
          sol[i] = last;
          ok = 1;
          break;
        }
        last = it->first + it->second;
      }
    }
    if (!ok) {
      v.push_back(make_pair((last), (d[i])));
      sol[i] = last;
    }
    cout << sol[i] << " " << sol[i] + d[i] - 1 << endl;
  }
  return 0;
}
