#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200 + 5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int N;
struct Rec {
  long long L, R;
  Rec() {}
  Rec(int L, int R) : L(L), R(R) {}
};
vector<Rec> rec;
inline bool Intersect(const Rec& a, const Rec& b) {
  return (b.L <= a.L && a.L <= b.R) || (b.L <= a.R && a.R <= b.R) ||
         (a.L <= b.L && b.L <= a.R) || (a.L <= b.R && b.R <= a.R);
}
bool conflict(const Rec& a) {
  for (int j = 0; j < rec.size(); j++) {
    if (Intersect(a, rec[j])) return true;
  }
  return false;
}
int main() {
  rec.clear();
  cin >> N;
  long long s, d;
  for (int i = 0; i < N; ++i) {
    cin >> s >> d;
    Rec temp = Rec(s, s + d - 1);
    long long now;
    if (conflict(temp)) {
      if (!conflict(Rec(1, d)))
        temp = Rec(1, d);
      else {
        now = INF;
        for (int j = 0; j < rec.size(); j++) {
          if (now <= rec[j].R + 1) continue;
          if (!conflict(Rec(rec[j].R + 1, rec[j].R + d))) now = rec[j].R + 1;
        }
        temp = Rec(now, now + d - 1);
      }
    }
    printf("%lld %lld\n", temp.L, temp.R);
    rec.push_back(temp);
  }
  return 0;
}
