#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& num) {
  bool start = false, neg = false;
  char c;
  num = 0;
  while ((c = getchar()) != EOF) {
    if (c == '-')
      start = neg = true;
    else if (c >= '0' && c <= '9') {
      start = true;
      num = num * 10 + c - '0';
    } else if (start)
      break;
  }
  if (neg) num = -num;
}
const int maxn = 205;
int s[205], d[205];
vector<pair<int, int> > now;
int main() {
  int n;
  read(n);
  for (int i = (1); i <= (n); i++) read(s[i]), read(d[i]);
  for (int i = (1); i <= (n); i++) {
    int fl = 1;
    d[i] = s[i] + d[i] - 1;
    for (int j = 0; j < now.size(); j++) {
      if (now[j].first <= s[i] && s[i] <= now[j].second) fl = 0;
      if (now[j].first <= d[i] && d[i] <= now[j].second) fl = 0;
      if (s[i] <= now[j].first && now[j].second <= d[i]) fl = 0;
    }
    if (fl) {
      now.push_back(make_pair(s[i], d[i]));
      printf("%d %d\n", s[i], d[i]);
      sort(now.begin(), now.end());
      continue;
    }
    int st = -1, lst = 1;
    for (int j = 0; j < now.size(); j++) {
      if (now[j].first - lst >= d[i] - s[i] + 1) st = lst;
      if (st != -1) break;
      if (j + 1 == now.size()) st = now[j].second + 1;
      lst = now[j].second + 1;
    }
    now.push_back(make_pair(st, st + d[i] - s[i]));
    printf("%d %d\n", st, st + d[i] - s[i]);
    sort(now.begin(), now.end());
  }
  return 0;
}
