#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int y, cost, size, max_a;
  node *l, *r;
  node(int y = 0, int cost = 0, node *left = NULL, node *right = NULL)
      : y(y), cost(cost), l(left), r(right) {
    max_a = cost;
    size = 1;
  }
  ~node() {
    delete l;
    delete r;
  }
};
typedef node *pnode;
class ImTreap {
 public:
  static void insert(pnode &t, pnode tmp, int i) {
    pnode left = NULL, right = NULL;
    split(t, i, left, right);
    merge(t, left, tmp);
    merge(t, t, right);
  }
  static void merge(pnode &t, pnode left, pnode right) {
    if (!left || !right)
      t = left ? left : right;
    else if (left->y > right->y)
      merge(left->r, left->r, right), t = left;
    else
      merge(right->l, left, right->l), t = right;
    recalc(t);
  }
  static void split(pnode t, int x, pnode &left, pnode &right) {
    if (!t) {
      left = right = NULL;
      return;
    }
    int cur = size_of(t->l) + 1;
    if (cur <= x) {
      left = t;
      split(left->r, x - cur, left->r, right);
      recalc(left);
    } else {
      right = t;
      split(right->l, x, left, right->l);
      recalc(right);
    }
  }
  static void recalc(pnode t) {
    if (!t) return;
    t->size = size_of(t->l) + size_of(t->r) + 1;
    t->max_a = max(t->cost, max(max_of(t->l), max_of(t->r)));
  }
  static int size_of(pnode t) { return t ? t->size : 0; }
  static int max_of(pnode t) { return t ? t->max_a : 0; }
};
int n;
vector<int> prior;
pnode t = NULL;
void insert(pnode &t, int a, int c) {
  if (!t) {
    t = new node(rand(), a);
    return;
  }
  pnode left = NULL, right = NULL;
  ImTreap::split(t, c, left, right);
  if (!left || a > left->max_a) {
    ImTreap::merge(left, left, new node(rand(), a));
    ImTreap::merge(t, left, right);
    return;
  }
  int l = 0, max_a = left->max_a;
  pnode tmp = left;
  while (tmp) {
    if (a > ImTreap::max_of(tmp->l) && a > tmp->cost) {
      l += ImTreap::size_of(tmp->l) + 1;
      max_a = ImTreap::max_of(tmp->r);
      tmp = tmp->r;
    } else {
      max_a = ImTreap::max_of(tmp->l);
      tmp = tmp->l;
    }
  }
  pnode sub_l = NULL, sub_r = NULL;
  ImTreap::split(left, l, sub_l, sub_r);
  ImTreap::merge(sub_l, sub_l, new node(rand(), a));
  ImTreap::merge(left, sub_l, sub_r);
  ImTreap::merge(t, left, right);
}
void traversal(pnode t) {
  if (!t) return;
  traversal(t->r);
  cout << prior[t->cost - 1] << ' ';
  traversal(t->l);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  prior.resize(n);
  for (int i = 0; i < n; i++) {
    int a, c;
    cin >> a >> c;
    prior[a - 1] = i + 1;
    insert(t, a, c);
  }
  traversal(t);
  delete t;
  return 0;
}
