#include <bits/stdc++.h>
using namespace std;
int add(int x, int y) {
  x += y;
  while (x >= 1000000007) x -= 1000000007;
  while (x < 0) x += 1000000007;
  return x;
}
int mul(int x, int y) { return (x * 1ll * y) % 1000000007; }
int binpow(int x, int y) {
  int z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
int inv(int x) { return binpow(x, 1000000007 - 2); }
int divide(int x, int y) { return mul(x, inv(y)); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<long long int, long long int> > v;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    v.push_back({a, b});
  }
  vector<pair<long long int, long long int> > sol, sols;
  for (int i = 0; i < n; i++) {
    long long int a = v[i].first, b = v[i].second + a - 1;
    int flag = 0;
    for (int j = 0; j < sols.size(); j++) {
      if (max(sols[j].first, a) <= min(sols[j].second, b)) flag = 1;
    }
    long long int pa = 1, push_back = v[i].second;
    for (int j = 0; j < sols.size(); j++) {
      if (max(sols[j].first, pa) <= min(sols[j].second, push_back)) {
        pa = sols[j].second + 1;
        push_back = pa + v[i].second - 1;
      }
    }
    if (flag == 0)
      sol.push_back({a, b});
    else
      sol.push_back({pa, push_back});
    sols = sol;
    sort(sols.begin(), sols.end());
  }
  for (int i = 0; i < n; i++)
    cout << sol[i].first << " " << sol[i].second << "\n";
  return 0;
}
