#include <bits/stdc++.h>
int l[200], r[200];
int n;
int check(int L, int R, int n) {
  for (int i = 0; i < n; i++)
    if ((l[i] <= L && L <= r[i]) || (l[i] <= R && R <= r[i]) ||
        (L <= l[i] && l[i] <= R) || (L <= r[i] && r[i] <= R))
      return i + 1;
  return 0;
}
int main() {
  int x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", l + i, r + i);
    if (check(l[i], l[i] + r[i] - 1, i) != 0) {
      l[i] = 1;
      while ((x = check(l[i], l[i] + r[i] - 1, i)) != 0) l[i] = r[x - 1] + 1;
    }
    r[i] = l[i] + r[i] - 1;
    printf("%d %d\n", l[i], r[i]);
  }
  return 0;
}
