#include <bits/stdc++.h>
using namespace std;
const int OFFSET = 5;
const int MAXN = 200 + OFFSET;
int N;
int start[MAXN], days[MAXN], pos[MAXN];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &start[i], &days[i]);
  }
  start[N] = 0;
  days[N] = 1;
  pos[0] = N;
  for (int i = 0; i < N; i++) {
    int j = i;
    while (start[pos[j]] > start[i]) {
      j--;
    }
    if (start[pos[j]] + days[pos[j]] - 1 < start[i] &&
        (j == i || start[i] + days[i] - 1 < start[pos[j + 1]])) {
      for (int k = i + 1; k >= j + 2; k--) {
        pos[k] = pos[k - 1];
      }
      pos[j + 1] = i;
    } else {
      for (j = 0; j < i; j++) {
        if (start[pos[j]] + days[pos[j]] + days[i] - 1 < start[pos[j + 1]]) {
          break;
        }
      }
      if (j == i) {
        start[i] = start[pos[i]] + days[pos[i]];
        pos[i + 1] = i;
      } else {
        for (int k = i + 1; k >= j + 2; k--) {
          pos[k] = pos[k - 1];
        }
        start[i] = start[pos[j]] + days[pos[j]];
        pos[j + 1] = i;
      }
    }
    printf("%d %d\n", start[i], start[i] + days[i] - 1);
  }
  return 0;
}
