#include <bits/stdc++.h>
using namespace std;
const long long maxn = 109;
const long long maxnn = 1e7 + 500;
long long r[maxn];
vector<long long> mas[maxnn];
long long ans[maxn];
int main() {
  long long n, lt, rt;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> lt >> rt;
    r[i] = rt;
    mas[lt].push_back(i);
  }
  long long v;
  set<pair<long long, long long> > st;
  for (long long i = 0; i < maxnn; i++) {
    for (long long j = 0; j < mas[i].size(); j++) {
      st.insert(make_pair(r[mas[i][j]], mas[i][j]));
    }
    if (!st.empty()) {
      ans[(*(st.begin())).second] = i;
      st.erase(st.begin());
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
}
