#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
struct node {
  int s[2], val, p, sz, maxn, id;
} tr[N];
int root, n, m, cnt;
void pushup(int u) {
  tr[u].sz = tr[tr[u].s[0]].sz + tr[tr[u].s[1]].sz + 1;
  int a = -1, b = -1;
  if (tr[u].s[0]) a = tr[tr[u].s[0]].maxn;
  if (tr[u].s[1]) b = tr[tr[u].s[1]].maxn;
  tr[u].maxn = max(max(a, b), tr[u].val);
}
void rotate(int x) {
  int y = tr[x].p, z = tr[y].p;
  int k = tr[y].s[1] == x;
  tr[z].s[tr[z].s[1] == y] = x;
  tr[x].p = z;
  tr[y].s[k] = tr[x].s[k ^ 1];
  tr[tr[x].s[k ^ 1]].p = y;
  tr[x].s[k ^ 1] = y;
  tr[y].p = x;
  pushup(y), pushup(x);
}
void splay(int x, int k) {
  while (tr[x].p != k) {
    int y = tr[x].p, z = tr[y].p;
    if (z != k) {
      if ((tr[y].s[1] == x) ^ (tr[z].s[1] == y)) {
        rotate(x);
      } else {
        rotate(y);
      }
    }
    rotate(x);
  }
  pushup(x);
  if (!k) root = x;
}
int newnode(int father, int val) {
  tr[++cnt] = {0, 0, val, father, 1, val};
  return cnt;
}
void insert(int &u, int fa, int val, int c, int id) {
  if (u == 0) {
    u = newnode(fa, val);
    tr[u].id = id;
    return;
  }
  if (val < tr[u].val || val < tr[tr[u].s[1]].maxn || c <= tr[tr[u].s[1]].sz) {
    insert(tr[u].s[1], u, val, c, id);
  } else {
    insert(tr[u].s[0], u, val, c - tr[tr[u].s[1]].sz - 1, id);
  }
  pushup(u);
}
void print(int u = root) {
  if (tr[u].s[0]) print(tr[u].s[0]);
  printf("%d ", tr[u].id);
  if (tr[u].s[1]) print(tr[u].s[1]);
}
void init() {}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    int a, c;
    scanf("%d%d", &a, &c);
    insert(root, 0, a, c, i);
    splay(cnt, 0);
  }
  print();
  puts("");
  return 0;
}
