#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T sqr(T root) {
  return root * root;
}
template <class T>
inline T lowbit(T n) {
  return n & (-n);
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
const double pi = acos(-1.0);
const double eps = (1e-1);
const int Dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
const int Dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double inf = 1e50;
const int mod = 123657;
const int MAXN = 10000 + 10;
const int MAXM = 200000 + 100;
map<int, int> dic;
int my[MAXN], mx[MAXN], mk[MAXN];
vector<int> g[100 + 10];
int idx;
vector<int> rev;
int dfs(int p) {
  for (int i = 0; i < g[p].size(); i++) {
    int x = g[p][i];
    if (mk[x] != idx) {
      mk[x] = idx;
      int py = my[x], px = mx[p];
      my[x] = p;
      mx[p] = x;
      if (py == -1 || dfs(py)) return 1;
      my[x] = py, mx[p] = px;
    }
  }
  return 0;
}
int main() {
  int N;
  scanf("%d", &N);
  int cnt = 0;
  for (int id = 0; id < (N); id++) {
    int l, r;
    scanf("%d%d", &l, &r);
    for (int i = l; i <= r; i++) {
      if (i - l + 1 > N) break;
      if (dic.find(i) == dic.end()) {
        dic[i] = cnt++;
        rev.push_back(i);
      }
      g[id].push_back(dic[i]);
    }
  }
  memset(my, -1, sizeof(my));
  cnt = 0;
  for (int i = 0; i < (N); i++) {
    ++idx;
    if (dfs(i)) cnt++;
  }
  if (cnt != N)
    while (1) puts("error");
  for (int i = 0; i < (N); i++) {
    if (i) putchar(' ');
    printf("%d", rev[mx[i]]);
  }
  putchar('\n');
}

### Prompt

Please create a solution in cpp to the following 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 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T sqr(T root) {
  return root * root;
}
template <class T>
inline T lowbit(T n) {
  return n & (-n);
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
const double pi = acos(-1.0);
const double eps = (1e-1);
const int Dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
const int Dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double inf = 1e50;
const int mod = 123657;
const int MAXN = 10000 + 10;
const int MAXM = 200000 + 100;
map<int, int> dic;
int my[MAXN], mx[MAXN], mk[MAXN];
vector<int> g[100 + 10];
int idx;
vector<int> rev;
int dfs(int p) {
  for (int i = 0; i < g[p].size(); i++) {
    int x = g[p][i];
    if (mk[x] != idx) {
      mk[x] = idx;
      int py = my[x], px = mx[p];
      my[x] = p;
      mx[p] = x;
      if (py == -1 || dfs(py)) return 1;
      my[x] = py, mx[p] = px;
    }
  }
  return 0;
}
int main() {
  int N;
  scanf("%d", &N);
  int cnt = 0;
  for (int id = 0; id < (N); id++) {
    int l, r;
    scanf("%d%d", &l, &r);
    for (int i = l; i <= r; i++) {
      if (i - l + 1 > N) break;
      if (dic.find(i) == dic.end()) {
        dic[i] = cnt++;
        rev.push_back(i);
      }
      g[id].push_back(dic[i]);
    }
  }
  memset(my, -1, sizeof(my));
  cnt = 0;
  for (int i = 0; i < (N); i++) {
    ++idx;
    if (dfs(i)) cnt++;
  }
  if (cnt != N)
    while (1) puts("error");
  for (int i = 0; i < (N); i++) {
    if (i) putchar(' ');
    printf("%d", rev[mx[i]]);
  }
  putchar('\n');
}

```