#include <bits/stdc++.h>
const int MAXN = 3e5 + 10;
const double eps = 1e-8;
using namespace std;
struct edge {
  int t, v;
  edge *next;
} e[MAXN << 1], *h[MAXN], *o = e;
void add(int x, int y, int vul) {
  o->t = y;
  o->v = vul;
  o->next = h[x];
  h[x] = o++;
}
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
int maxx[MAXN], ch[MAXN][2], key[MAXN], pre[MAXN], sz[MAXN];
int rt, n;
void Treavel(int x) {
  if (x) {
    Treavel(ch[x][0]);
    printf("结点%2d:左儿子 %2d 右儿子 %2d 父结点 %2d size=%2d,key=%2d\n", x,
           ch[x][0], ch[x][1], pre[x], sz[x], key[x]);
    Treavel(ch[x][1]);
  }
}
void debug(int rp) {
  printf("root:%d\n", rp);
  Treavel(rp);
}
void newnode(int x, int t, int fa) {
  maxx[x] = key[x] = t;
  ch[x][0] = ch[x][1] = 0;
  pre[x] = fa;
  sz[x] = 1;
}
void up(int x) {
  sz[x] = sz[ch[x][0]] + sz[ch[x][1]] + 1;
  maxx[x] = max(key[x], max(maxx[ch[x][0]], maxx[ch[x][1]]));
}
void rotate(int x, int kind) {
  int y = pre[x];
  pre[ch[x][kind]] = y;
  ch[y][!kind] = ch[x][kind];
  if (pre[y]) ch[pre[y]][ch[pre[y]][1] == y] = x;
  pre[x] = pre[y];
  ch[x][kind] = y;
  pre[y] = x;
  up(y);
}
void splay(int x, int goal) {
  while (pre[x] != goal) {
    if (pre[pre[x]] == goal)
      rotate(x, ch[pre[x]][0] == x);
    else {
      int y = pre[x];
      int kind = ch[pre[y]][0] == y;
      if (ch[y][kind] == x)
        rotate(x, !kind), rotate(x, kind);
      else
        rotate(y, kind), rotate(x, kind);
    }
  }
  if (goal == 0) rt = x;
  up(x);
}
int find1(int x, int t) {
  if (sz[ch[x][0]] + 1 == t) {
    return x;
  } else if (sz[ch[x][0]] >= t)
    return find1(ch[x][0], t);
  else
    return find1(ch[x][1], t - sz[ch[x][0]] - 1);
}
void inte() {
  rt = 1;
  newnode(1, 0, 0);
  newnode(n + 2, 0, 1);
  ch[1][1] = n + 2;
  up(rt);
}
void insert(int id, int pos) {
  splay(find1(rt, pos - 1), 0);
  splay(find1(rt, pos), rt);
  pre[id] = ch[rt][1];
  ch[ch[rt][1]][0] = id;
  up(ch[rt][1]);
  up(rt);
}
bool check(int l, int r, int t) {
  splay(find1(rt, l - 1), 0);
  splay(find1(rt, r + 1), rt);
  if (maxx[ch[ch[rt][1]][0]] <= t)
    return 1;
  else
    return 0;
}
int st[MAXN], tot;
void slove(int x) {
  if (!x) return;
  slove(ch[x][0]);
  st[++tot] = x;
  slove(ch[x][1]);
}
int main() {
  n = read();
  inte();
  int a, c;
  tot = 0;
  a = read();
  c = read();
  newnode(2, a, 0);
  insert(2, 2);
  for (int i = 2; i <= n; i++) {
    a = read();
    c = read();
    newnode(i + 1, a, 0);
    int l = 1;
    int r = c;
    int pos = i + 1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check(max(i - mid, 1) + 1, i, a))
        pos = max(i - mid, 1) + 1, l = mid + 1;
      else
        r = mid - 1;
    }
    insert(i + 1, pos);
  }
  slove(rt);
  for (int i = 2; i <= tot - 1; i++) printf("%d ", st[i] - 1);
  printf("\n");
}
