#include <bits/stdc++.h>
using namespace std;
int n;
int l[10000000];
int r[10000000];
int vis[10000000];
int ans[10000000];
bool check(int a, int b) {
  if (l[b] > l[a]) {
    return 1;
  } else {
    if (r[b] > r[a] && l[a] == l[b]) {
      return 1;
    } else {
      return 0;
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
  }
  l[0] = 100000000;
  r[0] = 100000000;
  for (int i = 1; i <= n; i++) {
    int k = 0;
    for (int j = 1; j <= n; j++) {
      if (!vis[j] && check(j, k)) {
        k = j;
      }
    }
    ans[k] = l[k];
    vis[k] = 1;
    for (int j = 1; j <= n; j++) {
      if (l[j] < ans[k] + 1) {
        l[j] = ans[k] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
