#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = tuple<int, int, int>;
using vi = vector<int>;
int main(void) {
  ios::sync_with_stdio(false), cin.tie(NULL);
  int n;
  cin >> n;
  vector<iii> a(n);
  int maxr = 0, i = 0;
  for (auto &[r, l, ix] : a) {
    cin >> l >> r;
    ix = i++;
    maxr = max(maxr, r);
  }
  sort(begin(a), end(a));
  vi used(maxr + 1, 0), ans(n);
  for (auto [r, l, i] : a) {
    while (used[l]) l++;
    ans[i] = l;
    used[l] = true;
  }
  for (auto x : ans) cout << x << " ";
  cout << endl;
  return 0;
}
