#include <bits/stdc++.h>
using namespace std;
long long int n, m, k;
long long int arr[10000005];
bool flag[10000005];
int main() {
  int n;
  cin >> n;
  vector<pair<int, pair<int, int> > > v;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(b, make_pair(a, i)));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    int y = v[i].first;
    int x = v[i].second.first;
    while (flag[x]) {
      x++;
    }
    flag[x] = true;
    arr[v[i].second.second] = x;
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
}
