#include <bits/stdc++.h>
using namespace std;
int n, sol[105], Left;
map<int, vector<pair<int, int>>> Int;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    Sel;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    Int[x].push_back(make_pair(y, i));
  }
  while (!Sel.empty() || !Int.empty()) {
    if (!Int.empty()) {
      map<int, vector<pair<int, int>>>::iterator it = Int.begin();
      if (Sel.empty() || it->first == Left) {
        Left = it->first;
        for (int i = 0; i < it->second.size(); i++) Sel.push(it->second[i]);
        Int.erase(it);
      }
    }
    sol[Sel.top().second] = Left;
    Sel.pop();
    ++Left;
  }
  for (int i = 1; i <= n; i++) cout << sol[i] << ' ';
}
