#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 42;
typedef struct treap *ptreap;
struct treap {
  int v, num, c, y, mmax;
  ptreap l, r;
  treap() {}
  treap(int v, int num)
      : v(v), num(num), c(1), y(rand()), mmax(v), l(0), r(0) {}
};
int cnt(ptreap t) { return t ? t->c : 0; }
int max(ptreap t) { return t ? t->mmax : -1; }
void recalc(ptreap t) {
  if (t) {
    t->c = cnt(t->l) + cnt(t->r) + 1;
    t->mmax = max(max(max(t->l), max(t->r)), t->v);
  }
}
void split(ptreap t, int key, ptreap &l, ptreap &r) {
  if (!t) {
    l = r = 0;
    return;
  }
  int cur_key = cnt(t->l);
  if (key < cur_key) {
    split(t->l, key, l, t->l);
    r = t;
  } else {
    split(t->r, key - cur_key - 1, t->r, r);
    l = t;
  }
  recalc(t);
}
void merge(ptreap l, ptreap r, ptreap &t) {
  if (!l || !r) {
    t = l ? l : r;
    return;
  }
  if (l->y < r->y) {
    merge(l->r, r, l->r);
    t = l;
  } else {
    merge(l, r->l, r->l);
    t = r;
  }
  recalc(t);
}
void print(ptreap t) {
  if (!t) return;
  print(t->l);
  cout << t->num << ' ';
  print(t->r);
}
ptreap t, q;
int n, a, c;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(time(0));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> c;
    ptreap tmp = new treap(a, i + 1);
    int l = max(-1, i - c - 1);
    int r = i + 1;
    while (r - l > 1) {
      int m = (l + r) / 2;
      q = 0;
      split(t, m - 1, q, t);
      if (max(t) > a && max(t) != inf)
        l = m;
      else
        r = m;
      merge(q, t, t);
    }
    split(t, r - 1, q, t);
    merge(q, tmp, q);
    merge(q, t, t);
  }
  print(t);
  return 0;
}
