#include <bits/stdc++.h>
using namespace std;
bool compare(tuple<long long, long long, long long> t1,
             tuple<long long, long long, long long> t2) {
  if (get<1>(t1) == get<1>(t2)) return get<0>(t1) < get<0>(t2);
  return get<1>(t1) < get<1>(t2);
}
int main() {
  long long n;
  cin >> n;
  vector<tuple<long long, long long, long long> > v(n);
  for (long long i = 0; i < n; i++) {
    cin >> get<0>(v[i]) >> get<1>(v[i]);
    get<2>(v[i]) = i + 1;
  }
  sort(v.begin(), v.end(), compare);
  vector<long long> ans(n + 1);
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    long long start = get<0>(v[i]);
    long long last = get<1>(v[i]);
    long long idx = get<2>(v[i]);
    for (long long j = start; j <= last; j++) {
      if (m[j] == 0) {
        m[j] = 1;
        ans[idx] = j;
        break;
      }
    }
  }
  for (long long i = 1; i <= n; i++) cout << ans[i] << " ";
}
