#include <bits/stdc++.h>
using namespace std;
const int G = 317;
vector<vector<int> > v;
vector<int> tv;
vector<int> ma;
int pos[100005];
int main() {
  int n, a, c;
  while (~scanf("%d", &n)) {
    v.clear();
    tv.clear();
    tv.push_back(100001);
    v.push_back(tv);
    ma.clear();
    ma.push_back(100001);
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &a, &c);
      pos[a] = i;
      int m = v.size(), j = 0, k = 0;
      for (; j < m; j++) {
        if (ma[j] > a || c <= v[j].size()) break;
        c -= v[j].size();
      }
      while (k < c && v[j][k] < a) ++k;
      v[j].insert(v[j].begin() + k, a);
      ma[j] = max(ma[j], a);
      int S = v[j].size();
      if (S > G) {
        if (j < m - 1 && v[j + 1].size() < G) {
          for (int t = S - 1; t >= G; t--) {
            v[j + 1].insert(v[j + 1].begin(), v[j][t]);
            ma[j + 1] = max(ma[j + 1], v[j][t]);
          }
        } else {
          tv.clear();
          int tma = 0;
          for (int t = G; t < S; t++) {
            tv.push_back(v[j][t]);
            tma = max(tma, v[j][t]);
          }
          v.insert(v.begin() + j + 1, tv);
          ma.insert(ma.begin() + j + 1, tma);
        }
        v[j].resize(G);
        ma[j] = 0;
        for (int t = 0; t < G; t++) ma[j] = max(ma[j], v[j][t]);
      }
    }
    tv.clear();
    int tot = v.size();
    for (int i = 0; i < tot; i++) {
      int t2 = v[i].size();
      for (int j = 0; j < t2; j++) tv.push_back(pos[v[i][j]]);
    }
    for (int i = n - 1; i >= 0; i--) printf("%d ", tv[i]);
    puts("");
  }
}
