#include <bits/stdc++.h>
const int INF = std::numeric_limits<int>::max() / 2;
const long long INFLL = std::numeric_limits<long long>::max() / 2;
int n;
std::vector<int> vec;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  vec.push_back(1);
  vec.push_back(INF);
  std::cin >> n;
  while (n--) {
    int s, d;
    std::cin >> s >> d;
    int i = std::upper_bound(vec.begin(), vec.end(), s) - vec.begin();
    if ((i & 1) && vec[i] - s >= d) {
      vec.insert(vec.begin() + i, s + d);
      vec.insert(vec.begin() + i, s);
      std::cout << s << ' ' << s + d - 1 << '\n';
    } else
      for (int i = 0; i != vec.size(); i += 2)
        if (vec[i + 1] - vec[i] >= d) {
          vec.insert(vec.begin() + i + 1, vec[i] + d);
          vec.insert(vec.begin() + i + 1, vec[i]);
          std::cout << vec[i] << ' ' << vec[i] + d - 1 << '\n';
          break;
        }
  }
  return 0;
}
