#include <bits/stdc++.h>
#pragma comment(linker, "/stack:102400000,102400000")
using namespace std;
const int N = 100015;
const int M = 10005;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double Pi = acos(-1.0);
int lowbit(int x) { return x & (-x); }
template <class T>
inline T f_min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T f_max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T f_abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T f_gcd(T a, T b) {
  return b == 0 ? a : f_gcd(b, a % b);
}
template <class T>
inline T f_Lcm(T a, T b) {
  return a / f_gcd(a, b) * b;
}
template <class T>
inline void f_swap(T &a, T &b) {
  T t = a;
  a = b;
  b = t;
}
bool is_digit(char a) {
  if (a >= '0' && a <= '9') return true;
  return false;
}
bool is_lowch(char a) {
  if (a >= 'a' && a <= 'z') return true;
  return false;
}
bool is_upch(char a) {
  if (a >= 'A' && a <= 'Z') return true;
  return false;
}
int a[N], num[N];
struct Splay_tree {
  int pre[N], ch[N][2], root, tot1, n;
  int size[N], value[N], ma[N], id[N];
  inline void print(int x) {
    if (x) {
      print(ch[x][0]);
      printf(
          "root = %d: le = %d, ri = %d, fa = %d, size = %d, value = %d, ma = "
          "%d, id = %d\n",
          x, ch[x][0], ch[x][1], pre[x], size[x], value[x], ma[x], id[x]);
      print(ch[x][1]);
    }
  }
  inline void debug() {
    cout << root << endl;
    for (int i = 1; i <= n; ++i) cout << id[i] << " ";
    cout << endl;
    print(root);
  }
  inline void add_node(int &i, int fa, int val, int _id) {
    n++;
    i = ++tot1;
    pre[i] = fa;
    size[i] = 1;
    ch[i][0] = ch[i][1] = 0;
    value[i] = ma[i] = val;
    id[i] = _id;
  }
  inline void push_up(int i) {
    ma[i] = f_max(value[i], f_max(ma[ch[i][0]], ma[ch[i][1]]));
    size[i] = size[ch[i][0]] + size[ch[i][1]] + 1;
  }
  inline void push_down(int i) {}
  inline void build(int &i, int L, int R, int fa) {
    if (L > R) return;
    int mid = L + R >> 1;
    if (L < mid) build(ch[i][0], L, mid - 1, i);
    if (R > mid) build(ch[i][1], mid + 1, R, i);
    push_up(i);
  }
  inline void init(int _n) {
    n = _n;
    ch[0][0] = ch[0][1] = pre[0] = size[0] = 0;
    root = tot1 = 0;
    add_node(root, 0, -1, 0);
    add_node(ch[root][1], root, -1, n + 1);
    n = 0;
    size[root] = 2;
    push_up(ch[root][1]);
    push_up(root);
  }
  inline void Rotate(int x, int kind) {
    int y = pre[x];
    ch[y][!kind] = ch[x][kind];
    pre[ch[x][kind]] = y;
    if (pre[y]) ch[pre[y]][ch[pre[y]][1] == y] = x;
    pre[x] = pre[y];
    ch[x][kind] = y;
    pre[y] = x;
    push_up(y);
  }
  inline void Splay(int x, int goal) {
    while (pre[x] != goal) {
      int y = pre[x];
      if (pre[y] == goal)
        Rotate(x, ch[y][0] == x);
      else {
        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);
      }
    }
    push_up(x);
    if (goal == 0) root = x;
  }
  inline void Rotate_to(int k, int goal) {
    int x = root;
    while (k != size[ch[x][0]]) {
      if (k < size[ch[x][0]])
        x = ch[x][0];
      else {
        k -= size[ch[x][0]] + 1;
        x = ch[x][1];
      }
    }
    Splay(x, goal);
  }
  inline int find_next(int x) {
    while (0 != size[ch[x][0]]) x = ch[x][0];
    return x;
  }
  inline int find_pre(int x) {
    while (size[ch[x][1]] != 0) x = ch[x][1];
    return x;
  }
  inline bool query(int l, int r, int x) {
    Rotate_to(l - 1, 0);
    Rotate_to(r + 1, root);
    return ma[ch[ch[root][1]][0]] > x;
  }
  inline void update(int x, int val, int _id) {
    Rotate_to(x - 1, 0);
    Rotate_to(x, root);
    add_node(ch[ch[root][1]][0], ch[root][1], val, _id);
    push_up(ch[root][1]);
    push_up(root);
  }
  inline int get(int x) {
    Rotate_to(x - 1, 0);
    Rotate_to(x + 1, root);
    return value[ch[ch[root][1]][0]];
  }
  int ans[N], cnt;
  inline void prin() {
    Rotate_to(0, 0);
    Rotate_to(n + 1, root);
    cnt = 0;
    dfs(ch[ch[root][1]][0]);
    for (int i = 0; i < cnt - 1; ++i) printf("%d ", ans[i]);
    printf("%d\n", ans[cnt - 1]);
  }
  inline void dfs(int x) {
    if (x) {
      dfs(ch[x][0]);
      ans[cnt++] = id[x];
      dfs(ch[x][1]);
    }
  }
} splay;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    splay.init(0);
    for (int i = 1; i <= n; ++i) {
      int x, y;
      scanf("%d%d", &x, &y);
      if (i == 1)
        splay.update(1, x, i);
      else {
        int L = 1, R = i - 1;
        if (L == R) {
          if (y == 0 || splay.get(1) > x)
            splay.update(2, x, i);
          else
            splay.update(1, x, i);
          continue;
        }
        while (R - L > 1) {
          int mid = L + R >> 1;
          if (splay.query(mid, i - 1, x))
            L = mid;
          else
            R = mid;
        }
        int len = i - R - 1, res1 = splay.get(R), res2 = splay.get(L);
        if (x > res1) len++;
        if (x > res1 && x > res2) len++;
        splay.update(i - f_min(len, y), x, i);
      }
    }
    splay.prin();
  }
  return 0;
}
