#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int>> ans;
vector<int> starts;
bool can(pair<int, int> cur) {
  for (auto i = (0); i < ((int)(ans.size())); ++i) {
    int l = max(cur.first, ans[i].first);
    int r = min(cur.second, ans[i].second);
    if (l <= r) {
      return false;
    }
  }
  return true;
}
void prepare() {}
void read() {}
void solve() {
  scanf("%d", &n);
  starts.push_back(1);
  for (auto i = (0); i < (n); ++i) {
    int s, d;
    scanf("%d%d", &s, &d);
    if (can(make_pair(s, s + d - 1))) {
      ans.push_back(make_pair(s, s + d - 1));
      starts.push_back(s + d);
    } else {
      for (auto j = (0); j < ((int)(starts.size())); ++j) {
        if (can(make_pair(starts[j], starts[j] + d - 1))) {
          starts.push_back(starts[j] + d);
          ans.push_back(make_pair(starts[j], starts[j] + d - 1));
          break;
        }
      }
    }
    printf("%d %d\n", ans.back().first, ans.back().second);
    sort(starts.begin(), starts.end());
  }
}
int main() {
  prepare();
  read();
  solve();
  return 0;
}
