#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
int n, i, j, l[101], r[101], R[101], M, uns[1001], w[1001], k;
set<int> L;
bool z[1001];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> l[i] >> r[i];
  L.clear();
  for (i = 1; i <= n; i++) L.insert(l[i]);
  memset(z, true, sizeof(z));
  M = 1;
  for (;;) {
    k = -1;
    for (j = 1; j <= n; j++)
      if (z[j] && l[j] <= M && r[j] >= M) {
        if (k == -1 || r[j] < r[k]) k = j;
      }
    if (k != -1) {
      uns[k] = M;
      M++;
      z[k] = false;
    } else {
      set<int>::iterator it;
      it = L.upper_bound(M);
      if (it != L.end())
        M = *it;
      else
        break;
    }
  }
  for (i = 1; i <= n; i++) cout << uns[i] << " ";
  cout << endl;
}
