#include <bits/stdc++.h>
using namespace std;
struct period {
  long long start, end;
  int id;
};
bool possible(long long start, long long end, vector<period>& schedule) {
  for (int i = 0; i < schedule.size(); i++) {
    period P = schedule[i];
    if (P.start <= end && start <= P.end) return false;
  }
  return true;
}
bool contains(vector<period>& schedule, long long start, long long duration) {
  return !possible(start, start + duration - 1, schedule);
}
bool comparePeriod(const period& a, const period& b) {
  return a.start < b.start;
}
long long popMin(vector<period>& schedule, long long duration) {
  long long start = 1, end = start + duration - 1;
  for (int i = 0; i < schedule.size(); i++) {
    period P = schedule[i];
    if (P.start <= end && start <= P.end) {
      start = P.end + 1;
      end = start + duration - 1;
    }
  }
  return start;
}
int main() {
  int n;
  cin >> n;
  vector<period> schedule;
  for (int i = 0; i < n; i++) {
    long long start, duration;
    cin >> start >> duration;
    if (contains(schedule, start, duration)) {
      start = popMin(schedule, duration);
    }
    period P = {start, start + duration - 1, i};
    schedule.push_back(P);
    sort(schedule.begin(), schedule.end(), comparePeriod);
  }
  long long soln[2][200];
  for (int i = 0; i < n; i++) {
    soln[0][schedule[i].id] = schedule[i].start;
    soln[1][schedule[i].id] = schedule[i].end;
  }
  for (int i = 0; i < n; i++) {
    cout << soln[0][i] << ' ' << soln[1][i] << endl;
  }
  return 0;
}
