#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
  for (auto& x : v) o << x << ' ';
  return o;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<pair<int, int> > intervals;
  intervals.emplace_back(0, 0);
  intervals.emplace_back(INT_MAX, INT_MAX);
  int n;
  cin >> n;
  vector<pair<int, int> > arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  for (int i = 0; i < n; i++) {
    int s, d;
    tie(s, d) = arr[i];
    bool taken = false;
    for (pair<int, int> inter : intervals) {
      if (s <= inter.first && (s + d - 1) >= inter.second) taken = true;
      if (s >= inter.first && s <= inter.second) taken = true;
      if ((s + d - 1) >= inter.first && (s + d - 1) <= inter.second)
        taken = true;
    }
    if (!taken) {
      cout << s << ' ' << s + d - 1 << endl;
      intervals.emplace_back(s, s + d - 1);
      sort(intervals.begin(), intervals.end());
    } else {
      for (int j = 0; j < (int)intervals.size() - 1; j++) {
        pair<int, int> p1 = intervals[j], p2 = intervals[j + 1];
        pair<int, int> gap = {p1.second + 1, p2.first - 1};
        if (gap.second - gap.first + 1 >= d) {
          intervals.emplace_back(gap.first, gap.first + d - 1);
          cout << gap.first << ' ' << gap.first + d - 1 << endl;
          sort(intervals.begin(), intervals.end());
          break;
        }
      }
    }
  }
}
