#include <bits/stdc++.h>
const double EPS = 1e-9;
const int MOD = 1000000007;
const int INF = 2000 * 1000 * 1000;
const int MAX = 1005;
using namespace std;
int popcount(int n) {
  bitset<32> b(n);
  return b.count();
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) {
  long long temp = gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
inline bool isInteger(const std::string& s) {
  if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+')))
    return false;
  char* p;
  strtol(s.c_str(), &p, 10);
  return (*p == 0);
}
pair<int, int> sol[205];
int main() {
  int n;
  cin >> n;
  set<pair<int, int>> sch;
  for (int i = 0; i < n; i++) {
    int s, d, e;
    cin >> s >> d;
    e = s + d - 1;
    int idx = 0, curs, cure, cursnx, curenx;
    bool f = 0;
    bool best = 1;
    for (auto j : sch) {
      int curs = j.first, cure = j.second;
      if (e < curs || s > cure)
        continue;
      else {
        best = 0;
        break;
      }
    }
    if (best)
      sol[i] = (make_pair(s, e)), sch.insert(make_pair(s, e));
    else {
      if (sch.begin()->first - d - 1 >= 0) {
        sol[i] = make_pair(1, d);
        sch.insert(sol[i]);
        continue;
      }
      for (auto j : sch) {
        if (!idx)
          curs = j.first, cure = j.second;
        else {
          cursnx = j.first, curenx = j.second;
          if (cursnx - cure - 1 >= e - s + 1) {
            f = 1;
            sol[i] = make_pair(cure + 1, cure + d);
            sch.insert(sol[i]);
            break;
          }
          curs = cursnx, cure = curenx;
        }
        idx++;
      }
      if (!f) {
        sol[i] =
            make_pair((--sch.end())->second + 1, (--sch.end())->second + d);
        sch.insert(sol[i]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << sol[i].first << " " << sol[i].second << endl;
  }
}
