#include <bits/stdc++.h>
using std::abs;
using std::bitset;
using std::cerr;
using std::cin;
using std::copy;
using std::cout;
using std::endl;
using std::fill;
using std::fixed;
using std::greater;
using std::lower_bound;
using std::map;
using std::max;
using std::min;
using std::next_permutation;
using std::pair;
using std::priority_queue;
using std::queue;
using std::reverse;
using std::rotate;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::tie;
using std::tuple;
using std::unique;
using std::unordered_map;
using std::unordered_set;
using std::upper_bound;
using std::vector;
int const INF = (int)1e9;
long long const INFL = (long long)1e18;
long double const PI = 3.1415926535897932384626433832795028;
int const N = 100100;
int a[N], c[N];
struct Node {
  int ind;
  int sz;
  int prior;
  int ma;
  Node *l, *r;
  Node() {}
  Node(int ind)
      : ind(ind),
        sz(1),
        prior(rand() | (rand() << 16)),
        ma(a[ind]),
        l(0),
        r(0) {}
};
int size(Node* v) { return v ? v->sz : 0; }
int maxa(Node* v) { return v ? v->ma : -INF; }
void update(Node* v) {
  if (v) {
    v->sz = 1 + size(v->l) + size(v->r);
    v->ma = max({a[v->ind], maxa(v->l), maxa(v->r)});
  }
}
Node* merge(Node* a, Node* b) {
  if (!a) return b;
  if (!b) return a;
  if (a->prior > b->prior) {
    a->r = merge(a->r, b);
    update(a);
    return a;
  } else {
    b->l = merge(a, b->l);
    update(b);
    return b;
  }
}
void split(Node* v, int cnt, Node*& l, Node*& r) {
  if (!v) {
    l = r = NULL;
    return;
  }
  if (size(v->l) >= cnt) {
    split(v->l, cnt, l, v->l);
    update(v);
    r = v;
  } else {
    split(v->r, cnt - 1 - size(v->l), v->r, r);
    update(v);
    l = v;
  }
}
int firstGreater(Node* v, int val) {
  int ret = 0;
  while (true) {
    if (maxa(v->l) > val) {
      v = v->l;
    } else if (a[v->ind] < val) {
      ret += 1 + size(v->l);
      v = v->r;
    } else {
      break;
    }
  }
  ret += size(v->l);
  return ret;
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a + i, c + i);
  }
  Node* H = NULL;
  for (int i = 0; i < n; ++i) {
    Node* cur = new Node(i);
    Node *L, *M, *R;
    split(H, c[i], L, R);
    if (maxa(L) < a[i]) {
      H = merge(L, merge(cur, R));
    } else {
      int cnt = firstGreater(L, a[i]);
      split(L, cnt, L, M);
      H = merge(L, merge(cur, merge(M, R)));
    }
  }
  for (int i = 0; i < n; ++i) {
    Node* cur;
    split(H, size(H) - 1, H, cur);
    printf("%d ", cur->ind + 1);
  }
  puts("");
}
int main() { solve(); }
