#include <bits/stdc++.h>
using namespace std;
const int maxn = 111111;
struct node {
  struct node *c[2], *fa;
  int id;
  int sz;
  int val;
  int mx;
  inline bool d() { return fa->c[0] == this; }
  inline void setc(int d, node *s) {
    c[d] = s;
    s->fa = this;
  }
  void up() {
    sz = c[0]->sz + c[1]->sz + 1;
    mx = max(val, max(c[0]->mx, c[1]->mx));
  }
} NODE[2 * maxn], *null = &NODE[0];
int top;
struct SplayTree {
  node *root;
  vector<int> ans;
  void Rotate(node *x, int f) {
    node *y = x->fa;
    y->setc(!f, x->c[f]);
    x->fa = y->fa;
    if (y->fa != null) y->fa->setc(!y->d(), x);
    x->setc(f, y);
    y->up();
  }
  void Splay(node *x, node *goal) {
    while (x->fa != goal) {
      if (x->fa->fa == goal)
        Rotate(x, x->d());
      else {
        int f = x->fa->d();
        x->d() == f ? Rotate(x->fa, f) : Rotate(x, !f);
        Rotate(x, f);
      }
    }
    x->up();
    if (goal == null) root = x;
  }
  void RTO(int k, node *goal) {
    node *x = root;
    while (x->c[0]->sz + 1 != k) {
      if (k < x->c[0]->sz + 1)
        x = x->c[0];
      else {
        k -= x->c[0]->sz + 1;
        x = x->c[1];
      }
    }
    Splay(x, goal);
  }
  node *new_node(node *fa, int v) {
    node *x = &NODE[++top];
    x->id = top;
    x->c[0] = x->c[1] = null;
    x->sz = 1;
    x->val = v;
    x->fa = fa;
    x->mx = v;
    return x;
  }
  void vist(node *x) {
    if (x != null) {
      vist(x->c[0]);
      if (x->val != maxn) ans.push_back(x->id - 1);
      vist(x->c[1]);
    }
  }
  void init() { root = new_node(null, maxn); }
  int find(node *x, int a, int b, int cnt) {
    if (cnt == b) return cnt;
    if (x == null) return -1;
    if (x->mx < a) {
      if (cnt + x->sz <= b)
        return cnt + x->sz;
      else
        return b;
    } else if (x->c[0]->mx < a) {
      if (x->val > a) {
        if (cnt + x->c[0]->sz <= b)
          return cnt + x->c[0]->sz;
        else
          return b;
      } else {
        if (cnt + x->c[0]->sz + 1 <= b) {
          int tmp = find(x->c[1], a, b, cnt + x->c[0]->sz + 1);
          if (tmp == -1)
            return cnt + x->c[0]->sz + 1;
          else
            return tmp;
        } else {
          return b;
        }
      }
    } else {
      int tmp = find(x->c[0], a, b, cnt);
      if (tmp == -1)
        return cnt;
      else
        return tmp;
    }
  }
  void gao(int a, int b) {
    int p = find(root, a, b, 0);
    if (p == 0) {
      RTO(1, null);
      node *tmp = new_node(root, a);
      root->setc(0, tmp);
      root->up();
    } else {
      RTO(p, null);
      RTO(p + 1, root);
      node *tmp = new_node(root->c[1], a);
      root->c[1]->setc(0, tmp);
      root->c[1]->up();
      root->up();
    }
  }
  void print() {
    vist(root);
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
      if (i) printf(" ");
      printf("%d", ans[i]);
    }
    puts("");
  }
} spt;
void prepare() {
  top = 0;
  null->id = 0;
  null->mx = 0;
  null->c[0] = null->c[1] = null->fa = NULL;
  null->sz = null->val = 0;
}
int main() {
  prepare();
  spt.init();
  int n, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a, &b);
    spt.gao(a, b);
  }
  spt.print();
  return 0;
}
