#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 11;
const double EPS = 1e-7;
const long long MOD = 1e9 + 7;
unsigned int SEED = 19260817;
const long long INF = 1ll << 60;
long long read() {
  long long x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline int Rand() {
  SEED = SEED * 1103515245 + 12345;
  return SEED / 65536;
}
struct Treap {
  int son[MAXN][2], root, tot;
  int val[MAXN], fix[MAXN], size[MAXN];
  long long mx[MAXN];
  int que[MAXN];
  void init() {
    root = 0;
    son[0][0] = son[0][1] = 0;
    val[0] = fix[0] = size[0] = 0;
    mx[0] = -INF;
    tot = 1;
  }
  int node(int v, int q) {
    son[tot][0] = son[tot][1] = 0;
    val[tot] = v;
    fix[tot] = Rand();
    size[tot] = 1;
    mx[tot] = v;
    que[tot] = q;
    return tot++;
  }
  void pu(int o) {
    size[o] = size[son[o][0]] + size[son[o][1]] + 1;
    mx[o] = max((long long)val[o], mx[son[o][0]]);
    mx[o] = max(mx[o], mx[son[o][1]]);
  }
  void split(int o, int k, int &a, int &b) {
    if (!o) {
      a = b = 0;
      return;
    } else if (k <= size[son[o][0]]) {
      b = o;
      split(son[o][0], k, a, son[o][0]);
      pu(o);
    } else {
      a = o;
      split(son[o][1], k - size[son[o][0]] - 1, son[o][1], b);
      pu(o);
    }
  }
  int merge(int a, int b) {
    if (!a) return b;
    if (!b) return a;
    if (fix[a] < fix[b]) {
      son[a][1] = merge(son[a][1], b);
      pu(a);
      return a;
    } else {
      son[b][0] = merge(a, son[b][0]);
      pu(b);
      return b;
    }
  }
  void insert(int pos, int v, int q) {
    int a, b, t = node(v, q);
    split(root, pos, a, b);
    root = merge(merge(a, t), b);
  }
  int get(int pos) {
    int a, b, x, y;
    split(root, pos - 1, a, b);
    split(b, 1, x, y);
    int t = x;
    root = merge(a, merge(x, y));
    return t;
  }
  int get(int pos, int len) {
    int a, b, x, y;
    split(root, pos - 1, a, b);
    split(b, len, x, y);
    int t = x;
    root = merge(a, merge(x, y));
    return t;
  }
  long long getmx(int pos, int len) {
    int a, b, x, y;
    split(root, pos - 1, a, b);
    split(b, len, x, y);
    long long t = mx[x];
    root = merge(a, merge(x, y));
    return t;
  }
} tp;
int n, p[MAXN], c[MAXN];
bool C(int st, int len) {
  if (len == 0) return 1;
  long long tmp = tp.getmx(st - len + 1, len);
  return p[st + 1] > tmp;
}
int main() {
  while (cin >> n) {
    for (register int i = 1; i <= n; i++) {
      p[i] = read();
      c[i] = read();
    }
    tp.init();
    tp.insert(1, p[1], 1);
    for (register int i = 2; i <= n; i++) {
      if (c[i] == 0) {
        tp.insert(i - 1, p[i], i);
        continue;
      }
      int l = 0, r = min(i - 1, c[i]), mid;
      while (l < r) {
        mid = l + (r - l + 1) / 2;
        if (C(i - 1, mid))
          l = mid;
        else
          r = mid - 1;
      }
      if (C(i - 1, l))
        tp.insert(i - l - 1, p[i], i);
      else
        tp.insert(i - 1, p[i], i);
    }
    for (register int i = 1; i <= n; i++) {
      int pos = tp.get(i);
      printf("%d%c", tp.que[pos], i == n ? '\n' : ' ');
    }
  }
  return 0;
}
