#include <bits/stdc++.h>
using namespace std;
const int MAXN = 205;
vector<pair<long long, long long> > res;
int n;
long long d[MAXN], s[MAXN];
bool check(pair<long long, long long> cur) {
  for (int i = 0; i < (int)(res.size()); i++)
    if (max(res[i].first, cur.first) <= min(res[i].second, cur.second))
      return false;
  return true;
}
pair<long long, long long> find(pair<long long, long long> cur) {
  long long left = -1;
  for (int i = 0; i < (int)(res.size()); i++)
    if (max(res[i].first, cur.first) <= min(res[i].second, cur.second)) {
      left = max(left, res[i].second + 1);
    }
  assert(left != -1);
  return make_pair(left, left - cur.first + cur.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < (int)(n); i++) cin >> d[i] >> s[i];
  for (int i = 0; i < (int)(n); i++) {
    pair<long long, long long> cur = make_pair(d[i], d[i] + s[i] - 1);
    if (!check(cur)) {
      cur = make_pair(1, s[i]);
      while (!check(cur)) cur = find(cur);
    }
    res.push_back(cur);
  }
  for (int i = 0; i < (int)(n); i++)
    cout << res[i].first << ' ' << res[i].second << '\n';
  return 0;
}
