#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167772160000")
using namespace std;
bool del[110];
void splitSegment(set<std::pair<int, int> > &segments,
                  set<std::pair<int, int> >::iterator it, int s, int d) {
  std::pair<int, int> seg = *it;
  segments.erase(it);
  if (s > seg.first) {
    segments.insert(make_pair(seg.first, s - seg.first));
  }
  if (s + d < seg.first + seg.second) {
    segments.insert(make_pair(s + d, seg.second - (s + d - seg.first)));
  }
  cout << s << " " << s + d - 1 << endl;
}
int main() {
  int n;
  cin >> n;
  set<std::pair<int, int> > segments;
  segments.insert(make_pair(1, 2000000000));
  while (n--) {
    int s, d;
    cin >> s >> d;
    auto it = segments.lower_bound(make_pair(s, 1));
    bool sposs = false;
    if (it == segments.end()) {
      sposs = true;
      it--;
      if (it->first <= s && it->second - (s - it->first) >= d) {
        sposs = true;
      }
    } else if (it->first == s && it->second - (s - it->first) >= d) {
      sposs = true;
    } else if (it->first > s && it != segments.begin()) {
      it--;
      if (it->first <= s && it->second - (s - it->first) >= d) {
        sposs = true;
      }
    }
    if (sposs) {
      splitSegment(segments, it, s, d);
    } else {
      for (auto it2 = segments.begin(); it2 != segments.end(); it2++) {
        int si = it2->first, di = it2->second;
        if (di >= d) {
          splitSegment(segments, it2, si, d);
          break;
        }
      }
    }
  }
  return 0;
}
