#include <bits/stdc++.h>
using namespace std;
struct E {
  int l, r, id;
  E(int l, int r, int id) : l(l), r(r), id(id) { ; }
};
bool operator<(const E &p, const E &q) { return p.r < q.r; }
int main() {
  int n, p, q;
  cin >> n;
  vector<E> pv;
  for (int i = 0; i < n; ++i) {
    cin >> p >> q;
    pv.push_back(E(p, q, i));
  }
  sort(pv.begin(), pv.end());
  set<int> used;
  vector<int> ans(n);
  for (int i = 0; i < pv.size(); ++i) {
    for (int j = pv[i].l; j <= pv[i].r; ++j) {
      if (used.find(j) == used.end()) {
        used.insert(j);
        ans[pv[i].id] = j;
        break;
      }
    }
  }
  for (int i = 0; i < n - 1; ++i) cout << ans[i] << " ";
  cout << ans[n - 1] << endl;
}
