#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e6 + 10;
bool inter(int x1, int y1, int x2, int y2) { return y1 >= x2 && y2 >= x1; }
int main() {
  vector<pair<int, int> > pp;
  int(n);
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    bool err = 0;
    for (int j = 0; j < (((int)(pp).size())); ++j)
      if (inter(x, x + y - 1, pp[j].first, pp[j].second)) {
        err = 1;
        break;
      }
    if (!err) {
      printf("%d %d\n", x, x + y - 1);
      pp.push_back(make_pair(x, x + y - 1));
    } else {
      int lt = 0;
      bool suc = 0;
      for (int j = 0; j < (((int)(pp).size())); ++j) {
        if (pp[j].first - lt - 1 >= y) {
          suc = 1;
          pp.push_back(make_pair(lt + 1, lt + y));
          printf("%d %d\n", lt + 1, lt + y);
          break;
        }
        lt = pp[j].second;
      }
      if (!suc) {
        printf("%d %d\n", pp.back().second + 1, pp.back().second + y);
        pp.push_back(make_pair(pp.back().second + 1, pp.back().second + y));
      }
    }
    sort((pp).begin(), (pp).end());
  }
  return 0;
}
