#include <bits/stdc++.h>
using namespace std;
struct Splaynode {
  Splaynode *fa, *ch[2];
  int a, key, id, tol, size;
  Splaynode(int _id, int _a) {
    fa = ch[0] = ch[1] = NULL;
    a = _a, id = _id;
    updata();
  }
  void updata() {
    key = tol = a;
    size = 1;
    if (ch[0]) size += ch[0]->size;
    if (ch[1]) size += ch[1]->size;
    if (ch[0]) tol = max(tol, ch[0]->tol);
    if (ch[1]) tol = max(tol, ch[1]->tol);
    if (ch[1]) key = max(key, ch[1]->tol);
  }
  void prit() {
    if (ch[0]) ch[0]->prit();
    if (id >= 0) printf("%d ", id, a, key);
    if (ch[1]) ch[1]->prit();
  }
};
struct SplayTree {
  Splaynode *root;
  void Rotate(Splaynode *x) {
    Splaynode *f = x->fa;
    int d = f->ch[1] == x;
    if (x->fa = f->fa) f->fa->ch[f->fa->ch[1] == f] = x;
    if (f->ch[d] = x->ch[d ^ 1]) f->ch[d]->fa = f;
    f->fa = x;
    x->ch[d ^ 1] = f;
    f->updata();
    x->updata();
  }
  void Splay(Splaynode *x) {
    while (x->fa)
      if (!x->fa->fa)
        Rotate(x);
      else {
        int d1 = x->fa->ch[1] == x, d2 = x->fa->fa->ch[1] == x->fa;
        if (d1 == d2)
          Rotate(x->fa), Rotate(x);
        else
          Rotate(x), Rotate(x);
      }
  }
  Splaynode *Select(Splaynode *tmp, int key) {
    if (!tmp) return NULL;
    if (tmp->key < key)
      return Select(tmp->ch[0], key);
    else {
      Splaynode *ret = Select(tmp->ch[1], key);
      return ret ? ret : tmp;
    }
  }
  Splaynode *SelectK(Splaynode *tmp, int num) {
    if (tmp->ch[0]) {
      if (tmp->ch[0]->size >= num) return SelectK(tmp->ch[0], num);
      num -= tmp->ch[0]->size;
    }
    if (num == 1) return tmp;
    return SelectK(tmp->ch[1], num - 1);
  }
  Splaynode *Meger(Splaynode *l, Splaynode *r) {
    if (!l) return r;
    if (!r) return l;
    l->ch[1] = Meger(l->ch[1], r);
    l->ch[1]->fa = l;
    l->updata();
    return l;
  }
  void insert(int id, int a, int c) {
    Splaynode *tmp = Select(root, a), *g, *h;
    Splay(tmp);
    if (tmp->ch[1] && tmp->ch[1]->size > c) {
      tmp = SelectK(tmp, tmp->size - c);
      Splay(tmp);
    }
    if (g = tmp->ch[1]) {
      tmp->ch[1] = NULL;
      g->fa = NULL;
      tmp->updata(), g->updata();
    }
    root = Meger(Meger(tmp, new Splaynode(id, a)), g);
  }
  void init() { root = new Splaynode(-1, 100010); }
  void prit() {
    root->prit();
    puts("");
  }
} tree;
int main() {
  int n, a, c;
  scanf("%d", &n);
  tree.init();
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &c);
    tree.insert(i + 1, a, c);
  }
  tree.prit();
  return 0;
}
