Problem: On a history lesson the teacher asked Vasya to name the dates when n famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [li, ri] (inclusive) on which the event could have taken place. However Vasya also remembers that there was at most one event in one day. Help him choose such n dates of famous events that will fulfill both conditions. It is guaranteed that it is possible.

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of known events. Then follow n lines containing two integers li and ri each (1 ≤ li ≤ ri ≤ 107) — the earliest acceptable date and the latest acceptable date of the i-th event.

Output

Print n numbers — the dates on which the events took place. If there are several solutions, print any of them. It is guaranteed that a solution exists.

Examples

Input

3
1 2
2 3
3 4


Output

1 2 3 


Input

2
1 3
1 3


Output

1 2 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void dbvar() { cerr << "]" << endl; }
template <class H, class... T>
void dbvar(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  dbvar(t...);
}
const long long int inf = (long long int)1e18;
const int mod = (long long int)1e9 + 7;
const long double eps = (long double)1e-9;
const long double pi = acos(-1.0);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int d8x[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int d8y[8] = {0, 1, 1, 1, 0, -1, -1, -1};
long long int power(long long int n, long long int m) {
  if (m == 0) return 1;
  long long int val = power(n, m / 2);
  if (m % 2 == 0)
    return (val * val);
  else
    return ((val * val) * n);
}
long long int powermod(long long int n, long long int m, long long int _MOD) {
  if (m == 0) return 1;
  long long int val = powermod(n, m / 2, _MOD);
  val %= _MOD;
  if (m % 2 == 0)
    return (val * val) % _MOD;
  else
    return (((val * val) % _MOD) * n) % _MOD;
}
int mult(long long int a, long long int b) { return (a * b) % 1000000007; }
int pot(int n, int k) {
  if (k == 0) return 1;
  long long int a = pot(n, k / 2);
  a = mult(a, a);
  if (k % 2)
    return mult(a, n);
  else
    return a;
}
int divide(int a, int b) { return mult(a, pot(b, 1000000007 - 2)); }
int sub(int a, int b) {
  if (a - b >= 0) return a - b;
  return a - b + 1000000007;
}
int add(int a, int b) {
  if (a + b >= 1000000007) return a + b - 1000000007;
  return a + b;
}
const int mxN = 110;
int n;
vector<pair<pair<int, int>, int> > arr;
void solve() {
  cin >> n;
  arr = vector<pair<pair<int, int>, int> >(n);
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first.second >> arr[i].first.first;
    arr[i].second = i;
  }
  sort(arr.begin(), arr.end());
  set<int> vis;
  for (int i = 0; i < n; i++) {
    for (int j = arr[i].first.second; j <= arr[i].first.first; j++) {
      if (vis.find(j) == vis.end()) {
        vis.insert(j);
        ans[arr[i].second] = j;
        break;
      }
    }
  }
  for (auto x : ans) cout << x << " ";
  cout << "\n";
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}