#include <bits/stdc++.h>
using namespace std;
map<int, bool> taken;
bool compare(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.second.second < b.second.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, pair<int, int> > > events;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    events.push_back(make_pair(i, make_pair(x, y)));
  }
  int count = 1;
  sort(events.begin(), events.end(), compare);
  vector<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    for (int j = events[i].second.first; j <= events[i].second.second; j++) {
      if (!taken[j]) {
        ans.push_back(make_pair(events[i].first, j));
        taken[j] = true;
        break;
      }
    }
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < n; i++) cout << ans[i].second << " ";
  return 0;
}
