#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int ts, kk = 1;
int n;
pair<long long int, long long int> a[205], b[205];
long long int st[205];
int sz;
int main() {
  int t, i, j, k;
  scanf("%d", &n);
  for (i = 1; i < n + 1; i++) {
    scanf("%lld%lld", &a[i].first, &a[i].second);
    a[i].second = a[i].first + a[i].second - 1;
  }
  a[0] = pair<long long int, long long int>(0, 0);
  st[0] = 0;
  sz = 1;
  for (i = 1; i < n + 1; i++) {
    bool g = 1;
    for (j = 0; j < i; j++) {
      if (a[j].second < a[i].first || a[j].first > a[i].second)
        ;
      else {
        g = 0;
        break;
      }
    }
    if (!g) {
      sort(st, st + sz);
      for (k = 0; k < sz; k++) {
        b[i].first = st[k] + 1;
        b[i].second = b[i].first + a[i].second - a[i].first;
        g = 1;
        for (j = 0; j < i; j++) {
          if (a[j].second < b[i].first || a[j].first > b[i].second)
            ;
          else {
            g = 0;
            break;
          }
        }
        if (g) break;
      }
      a[i] = b[i];
    }
    st[sz++] = a[i].second;
  }
  for (i = 1; i < n + 1; i++) printf("%lld %lld\n", a[i].first, a[i].second);
  return 0;
}
