#include <bits/stdc++.h>
using namespace std;
list<pair<int, int> > l;
int main() {
  int n;
  scanf("%d", &n);
  l.push_front(make_pair(1, 2e9));
  for (; n--;) {
    int s, d;
    scanf("%d%d", &s, &d);
    int ans1 = -1, ans2 = -1;
    for (list<pair<int, int> >::iterator it = l.begin(); it != l.end(); it++) {
      if (it->first > s) break;
      if (it->first <= s && it->second >= s + d - 1) {
        ans1 = s;
        ans2 = s + d - 1;
        if (s > 1) l.insert(it, make_pair(it->first, s - 1));
        it->first = s + d;
      }
    }
    if (ans1 == -1) {
      for (list<pair<int, int> >::iterator it = l.begin(); it != l.end(); it++)
        if (it->second - it->first + 1 >= d) {
          ans1 = it->first;
          ans2 = it->first + d - 1;
          if (it->second - it->first + 1 - d > 0)
            it->first += d;
          else
            l.erase(it);
          break;
        }
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}
