#include <bits/stdc++.h>
using namespace std;
class item {
 public:
  int maximp;
  int cnt;
  int chelnum;
  int imp;
  int prior;
  item *l, *r;
  item(int importance, int numb, int prior_)
      : maximp(importance),
        cnt(1),
        chelnum(numb),
        imp(importance),
        prior(prior_),
        l(NULL),
        r(NULL){};
};
typedef item* pitem;
int getc(pitem i) {
  if (i == NULL)
    return 0;
  else
    return i->cnt;
}
int getmaximp(pitem i) {
  if (NULL == i)
    return 0;
  else
    return i->maximp;
}
void upd(pitem i) {
  if (i != NULL) {
    i->cnt = getc(i->l) + 1 + getc(i->r);
    i->maximp = max(i->imp, max(getmaximp(i->l), getmaximp(i->r)));
  }
}
void merge(pitem& t, pitem l, pitem r) {
  if (!l || !r) {
    t = l ? l : r;
    return;
  }
  if (l->prior > r->prior) {
    t = l;
    merge(t->r, t->r, r);
  } else {
    t = r;
    merge(t->l, l, t->l);
  }
  upd(t);
}
void smartSplit(int importance, int maxkey, pitem t, pitem& l, pitem& r) {
  if (t == NULL) {
    l = r = NULL;
    return;
  }
  int rootkey = getc(t->l);
  if (maxkey <= rootkey || importance <= max(t->imp, getmaximp(t->l))) {
    r = t;
    smartSplit(importance, maxkey, t->l, l, r->l);
  } else {
    l = t;
    smartSplit(importance, maxkey - (rootkey + 1), t->r, l->r, r);
  }
  upd(t);
}
void printtree(pitem t) {
  if (t == NULL) return;
  printtree(t->r);
  printf("%d ", t->chelnum);
  printtree(t->l);
}
int main() {
  int n;
  cin >> n;
  vector<int> priors(n);
  for (int i = 0; i < n; ++i) priors[i] = i + 1;
  random_shuffle(priors.begin(), priors.end());
  pitem tree = NULL;
  for (int i = 0; i < n; ++i) {
    int impor, key;
    scanf("%d%d", &impor, &key);
    pitem l, r;
    smartSplit(impor, key, tree, l, r);
    pitem newitem = new item(impor, i + 1, priors[i]);
    merge(l, l, newitem);
    merge(tree, l, r);
  }
  printtree(tree);
  printf("\n");
  return 0;
}
