#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<long long, long long> > prom(3);
  int first_day, period;
  cin >> first_day >> period;
  cout << first_day << ' ' << first_day + period - 1 << endl;
  prom[0].first = 0;
  prom[0].second = 0;
  prom[1].first = first_day;
  prom[1].second = first_day + period - 1;
  prom[2].first = 1e10;
  prom[2].second = 1e10;
  int answ = 0;
  for (long long i = 2; i < n + 1; i++) {
    bool met = true, met2 = true;
    cin >> first_day >> period;
    for (long long j = 0; j < i; j++) {
      if (first_day + period - 1 < prom[j + 1].first &&
          first_day > prom[j].second) {
        prom.push_back(make_pair(first_day, first_day + period - 1));
        cout << first_day << ' ' << first_day + period - 1 << endl;
        sort(prom.begin(), prom.end());
        met2 = false;
        break;
      } else if (period < (prom[j + 1].first - prom[j].second) && met) {
        met = false;
        answ = j;
      }
    }
    if (!met && met2) {
      prom.push_back(
          make_pair(prom[answ].second + 1, prom[answ].second + period));
      cout << prom[answ].second + 1 << ' ' << prom[answ].second + period
           << endl;
      sort(prom.begin(), prom.end());
    } else if (met2 && met) {
      prom.push_back(
          make_pair(prom[i - 1].second + 1, prom[i - 1].second + period));
      cout << prom[i - 1].second + 1 << ' ' << prom[i - 1].second + period
           << endl;
      sort(prom.begin(), prom.end());
    }
  }
  return 0;
}
