#include <bits/stdc++.h>
using namespace std;
int sz, rt, fa[1000010], val[1000010], maxn[1000010], siz[1000010], re[1000010],
    son[1000010][2];
int n, a[1000010], c[1000010];
inline void clear(int x) {
  fa[x] = val[x] = siz[x] = re[x] = son[x][0] = son[x][1] = 0;
}
inline int get(int x) { return son[fa[x]][1] == x; }
inline void update(int x) {
  siz[x] = re[x] + siz[son[x][0]] + siz[son[x][1]];
  int p = a[val[x]], ls = a[maxn[son[x][0]]], rs = a[maxn[son[x][1]]];
  if (p > ls && p > rs)
    maxn[x] = val[x];
  else
    maxn[x] = maxn[son[x][ls < rs]];
}
inline void connect(int x, int y, int w) {
  if (x) fa[x] = y;
  if (y) son[y][w] = x;
}
void rotate(int x) {
  int f = fa[x], gf = fa[f], m = get(x), n = get(f);
  connect(son[x][m ^ 1], f, m);
  connect(f, x, m ^ 1);
  connect(x, gf, n);
  update(f), update(x);
}
void splay(int x) {
  for (int f; f = fa[x]; rotate(x))
    if (fa[f]) rotate(get(f) == get(x) ? f : x);
  rt = x;
}
void insert(int &x, int f, int v) {
  if (!x) {
    x = ++sz;
    fa[x] = f, val[x] = maxn[x] = v, siz[x] = re[x] = 1;
    return;
  }
  if (a[v] > a[maxn[son[x][1]]] && a[v] > a[val[x]])
    insert(son[x][0], x, v);
  else
    insert(son[x][1], x, v);
}
int find(int k) {
  int now = rt;
  while (siz[son[now][0]] + 1 != k) {
    if (k <= siz[son[now][0]])
      now = son[now][0];
    else
      k -= siz[son[now][0]] + 1, now = son[now][1];
  }
  return now;
}
void mid_print(int x) {
  if (son[x][0]) mid_print(son[x][0]);
  cout << val[x] << ' ';
  if (son[x][1]) mid_print(son[x][1]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], cin >> c[i];
  for (int i = 1; i <= n; i++) {
    if (i - c[i] <= 1)
      insert(rt, 0, i);
    else
      splay(find(i - c[i] - 1)), insert(son[rt][1], rt, i);
    splay(sz);
  }
  mid_print(rt);
  return 0;
}
