#include <bits/stdc++.h>
using namespace std;
vector<int> III(int a, int b, int c) {
  vector<int> r(3);
  r[0] = a;
  r[1] = b;
  r[2] = c;
  return r;
}
int main() {
  int n;
  cin >> n;
  vector<vector<int> > events;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    events.push_back(III(l, r, i));
  }
  int last = -5;
  sort(events.begin(), events.end());
  vector<pair<int, int> > r;
  while (events.size()) {
    assert(last + 1 <= events[0][1]);
    r.push_back(pair<int, int>(events[0][2], max(last + 1, events[0][0])));
    last = r[r.size() - 1].second;
    for (int i = 0; i < events.size(); i++) {
      events[i][0] = max(events[i][0], last + 1);
    }
    events.erase(events.begin());
    sort(events.begin(), events.end());
  }
  sort(r.begin(), r.end());
  for (int i = 0; i < r.size(); i++) {
    cout << r[i].second << " ";
  }
  cout << endl;
  return 0;
}
