#include <bits/stdc++.h>
inline int max(int a, int b) { return a > b ? a : b; }
struct Node {
  int index, num, height, size, maxnum;
  Node *L, *R;
  Node(int a, int b) {
    index = a;
    num = maxnum = b;
    height = rand();
    size = 1;
    L = R = NULL;
  }
  ~Node() {
    delete L;
    delete R;
  }
};
int size(Node *p) { return p == NULL ? 0 : p->size; }
int maxnum(Node *p) { return p == NULL ? -(1 << 28) : p->maxnum; }
void update(Node *p) {
  p->size = size(p->L) + size(p->R) + 1;
  p->maxnum = max(p->num, max(maxnum(p->L), maxnum(p->R)));
}
Node *zig(Node *p) {
  Node *q = p->L;
  p->L = q->R;
  q->R = p;
  update(p);
  update(q);
  return q;
}
Node *zag(Node *p) {
  Node *q = p->R;
  p->R = q->L;
  q->L = p;
  update(p);
  update(q);
  return q;
}
Node *insert(Node *p, int num, int cnt, int index) {
  if (p == NULL) {
    return new Node(index, num);
  }
  if (cnt >= size(p->R) + 1 && num > maxnum(p->R) && num > p->num) {
    p->L = insert(p->L, num, cnt - size(p->R) - 1, index);
    if (p->L->height < p->height) {
      p = zig(p);
    }
  } else {
    p->R = insert(p->R, num, cnt, index);
    if (p->R->height < p->height) {
      p = zag(p);
    }
  }
  update(p);
  return p;
}
bool first;
void print(Node *p) {
  if (p->L) {
    print(p->L);
  }
  if (first) {
    first = false;
  } else {
    printf(" ");
  }
  printf("%d", p->index);
  if (p->R) {
    print(p->R);
  }
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    Node *root = NULL;
    for (int i = 1; i <= n; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      root = insert(root, a, b, i);
    }
    first = true;
    print(root);
    puts("");
  }
  return 0;
}
