#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<long long, long long>> segs;
void solve() {
  segs.emplace_back(-1, 0);
  segs.emplace_back((long long)4e9, (long long)4e9 + 1);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    sort(segs.begin(), segs.end());
    long long s, d;
    scanf("%lld%lld", &s, &d);
    for (int j = 1; j < (int)segs.size(); j++)
      if (s < segs[j].first) {
        if (segs[j - 1].second < s && s + d - 1 < segs[j].first)
          segs.emplace_back(s, s + d - 1);
        else {
          for (int k = 1; k < (int)segs.size(); k++) {
            if (segs[k - 1].second + d < segs[k].first) {
              segs.emplace_back(segs[k - 1].second + 1, segs[k - 1].second + d);
              break;
            }
          }
        }
        break;
      }
    printf("%lld %lld\n", segs.back().first, segs.back().second);
  }
}
int main() {
  solve();
  (void)0;
  return 0;
}
