#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (int i = 0; i < n; i++) {
    long long s, e;
    cin >> s >> e;
    e = s + e - 1;
    bool b = true;
    for (int j = 0; j < v.size(); j++) {
      if (v[j].first <= e && v[j].second >= s) {
        b = false;
      }
    }
    if (b) {
      v.push_back(make_pair(s, e));
    } else {
      e -= s;
      e += 1;
      s = 1;
      bool b = true;
      for (int j = 0; j < v.size(); j++) {
        if (v[j].first <= e && v[j].second >= s) {
          b = false;
        }
      }
      if (b) {
        v.push_back(make_pair(s, e));
      } else {
        long long d = e;
        for (int j = 0; j < v.size(); j++) {
          s = v[j].second + 1;
          e = v[j].second + d;
          bool b = true;
          for (int j = 0; j < v.size(); j++) {
            if (v[j].first <= e && v[j].second >= s) {
              b = false;
            }
          }
          if (b) {
            v.push_back(make_pair(s, e));
            break;
          }
        }
      }
    }
    sort(v.begin(), v.end());
    cout << s << " " << e << endl;
  }
}
