#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
bool between(const long long &a1, const long long &a2, const long long &b1,
             const long long &b2) {
  if (a2 < b1 || b2 < a1)
    return false;
  else
    return true;
}
int main() {
  int s[205], d[205], n;
  vector<pair<long long, long long> > ans;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    cin >> d[i];
  }
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < i; j++) {
      if (between(s[i], s[i] + d[i] - 1, ans[j].first, ans[j].second)) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      for (long long k = 1;; k++) {
        bool f = true;
        for (int j = 0; j < i; j++) {
          if (between(k, k + d[i] - 1, ans[j].first, ans[j].second)) {
            f = false;
            k = ans[j].second;
            break;
          }
        }
        if (f) {
          ans.push_back(make_pair(k, k + d[i] - 1));
          break;
        }
      }
    } else {
      ans.push_back(make_pair(s[i], s[i] + d[i] - 1));
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << ' ' << ans[i].second << endl;
  }
  return 0;
}
