#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
const double eps = 1e-7;
long long n;
long long a[100005];
long long c[100005];
long long tree[100005];
long long ch[100005][2];
long long siz[100005];
long long fa[100005];
long long v[100005];
long long root;
long long now;
long long per;
long long tot;
long long num[100005];
vector<long long> liu;
void pushup(long long id) {
  siz[id] = siz[ch[id][0]] + siz[ch[id][1]] + 1;
  tree[id] = max(tree[ch[id][0]], tree[ch[id][1]]);
  tree[id] = max(tree[id], v[id]);
}
void rotate(long long x, long long &k) {
  long long y = fa[x];
  long long z = fa[y];
  long long kind;
  if (ch[y][0] == x) {
    kind = 1;
  } else {
    kind = 0;
  }
  if (y == k) {
    k = x;
  } else {
    if (ch[z][0] == y) {
      ch[z][0] = x;
    } else {
      ch[z][1] = x;
    }
  }
  ch[y][kind ^ 1] = ch[x][kind];
  fa[ch[y][kind ^ 1]] = y;
  ch[x][kind] = y;
  fa[y] = x;
  fa[x] = z;
  pushup(y);
  pushup(x);
}
void splay(long long x, long long &k) {
  while (x != k) {
    long long y = fa[x];
    long long z = fa[y];
    if (y != k) {
      if ((ch[y][0] == x) ^ (ch[z][0] == y)) {
        rotate(x, k);
      } else {
        rotate(y, k);
      }
    }
    rotate(x, k);
  }
}
long long frank(long long id, long long k) {
  long long h = siz[ch[id][1]];
  if (k == h + 1) {
    return id;
  } else if (k < h + 1) {
    return frank(ch[id][1], k);
  } else {
    return frank(ch[id][0], k - h - 1);
  }
}
void f(long long inde, long long val) {
  if (inde == 0) {
    return;
  } else if (tree[ch[inde][1]] < val && v[inde] < val) {
    now = inde;
    f(ch[inde][0], val);
  } else {
    f(ch[inde][1], val);
  }
}
void ask(long long inde) {
  if (ch[inde][0] != 0) {
    ask(ch[inde][0]);
  }
  if (num[inde] != 1000000000000 && num[inde] != -1000000000000) {
    liu.push_back(num[inde]);
  }
  if (ch[inde][1] != 0) {
    ask(ch[inde][1]);
  }
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld", &a[i], &c[i]);
    c[i]++;
    if (i == 1) {
      tot++;
      num[tot] = 1;
      root = 1;
      v[1] = a[i];
      siz[1] = 3;
      tree[1] = 1000000000000;
      tot++;
      num[tot] = -1000000000000;
      tree[2] = 1000000000000;
      v[2] = 1000000000000;
      ch[1][0] = 2;
      fa[2] = 1;
      siz[2] = 1;
      tot++;
      num[tot] = -1000000000000;
      tree[3] = -1000000000000;
      v[3] = -1000000000000;
      ch[1][1] = 3;
      fa[3] = 1;
      siz[3] = 1;
      continue;
    }
    long long k = min(tot, c[i] + 1);
    long long inde = frank(root, k);
    splay(inde, root);
    now = 0;
    f(ch[root][1], a[i]);
    splay(now, root);
    per = ch[now][0];
    while (ch[per][1] != 0) {
      per = ch[per][1];
    }
    tree[++tot] = a[i];
    num[tot] = i;
    v[tot] = a[i];
    siz[tot] = 1;
    fa[tot] = per;
    ch[per][1] = tot;
    per = tot;
    while (per != 0) {
      pushup(per);
      per = fa[per];
    }
  }
  ask(root);
  for (long long i = 0; i < liu.size(); i++) {
    cout << liu[i] << " ";
  }
  cout << endl;
  return 0;
}
