#include <bits/stdc++.h>
using namespace std;
int n, a[100], b[100];
vector<int> mp, sol;
vector<vector<int> > in;
int idx(int &v) { return lower_bound(mp.begin(), mp.end(), v) - mp.begin(); }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a + i, b + i);
    for (int j = a[i]; j <= b[i] && j <= a[i] + 100; ++j) mp.push_back(j);
    if (mp.back() != b[i]) mp.push_back(b[i]);
  }
  sort(mp.begin(), mp.end());
  mp.resize(unique(mp.begin(), mp.end()) - mp.begin());
  in.resize(mp.size());
  for (int i = 0; i < n; ++i) {
    a[i] = idx(a[i]);
    b[i] = idx(b[i]);
    in[a[i]].push_back(i);
  }
  sol.resize(n);
  priority_queue<pair<int, int> > q;
  for (int i = 0; i < in.size(); ++i) {
    for (int j = 0; j < in[i].size(); ++j)
      q.push(make_pair(-b[in[i][j]], in[i][j]));
    if (!q.empty()) {
      sol[q.top().second] = mp[i];
      q.pop();
    }
  }
  for (int i = 0; i < n; ++i) printf("%d ", sol[i]);
  return 0;
}
