#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
bool compare(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.second < b.second;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<pair<pair<int, int>, int> > busy;
  for (int i = 1; i <= n; i++) {
    int s, d;
    cin >> s >> d;
    d--;
    bool ok = true;
    for (auto j = busy.begin(); j != busy.end(); j++) {
      int beg = s, end = s + d;
      if (!(j->first.first > end || j->first.second < beg)) {
        ok = false;
        break;
      }
    }
    if (ok)
      busy.insert(pair<pair<int, int>, int>(pair<int, int>(s, s + d), i));
    else {
      int beg = 1, end = 1 + d;
      for (auto j = busy.begin(); j != busy.end(); j++) {
        if (j->first.first > end || j->first.second < beg) {
          busy.insert(pair<pair<int, int>, int>(pair<int, int>(beg, end), i));
          break;
        } else {
          beg = j->first.second + 1;
          end = beg + d;
        }
      }
      if (busy.find(pair<pair<int, int>, int>(pair<int, int>(beg, end), i)) ==
          busy.end()) {
        busy.insert(pair<pair<int, int>, int>(pair<int, int>(beg, end), i));
      }
    }
  }
  vector<pair<pair<int, int>, int> > ans;
  for (auto i = busy.begin(); i != busy.end(); i++) ans.push_back(*i);
  sort(ans.begin(), ans.end(), compare);
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first.first << ' ' << ans[i].first.second << endl;
  return 0;
}
