#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  set<pair<pair<int, int>, int>> sp;
  int res[n];
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    sp.insert({{r - l + 1, l}, i});
  }
  set<int> si;
  for (auto it : sp) {
    int d;
    if (it.second % 2 == 0) {
      d = 1;
      res[it.second] = it.first.second;
    } else {
      d = -1;
      res[it.second] = it.first.second + it.first.first - 1;
    }
    while (si.count(res[it.second])) {
      res[it.second] += d;
    }
    si.insert(res[it.second]);
  }
  for (int i = 0; i < n; i++) cout << res[i] << " ";
  return 0;
}
