#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 10, SQ = 300 + 10;
int a[N], c[N], pos[N], wh[N];
int mx[SQ + 100];
deque<int> dq[SQ + 100];
int lst = 0;
void add(int ind) {
  int x = lst, t = 0;
  while (x > 0 && t + (int)dq[x].size() <= c[ind] && mx[x] <= a[ind]) {
    t += (int)dq[x].size(), x--;
  }
  vector<int> temp;
  while (t < c[ind] && !dq[x].empty() && dq[x].back() < a[ind]) {
    temp.push_back(dq[x].back());
    dq[x].pop_back();
    t++;
  }
  dq[x].push_back(a[ind]);
  while (!temp.empty()) {
    dq[x].push_back(temp[(int)temp.size() - 1]);
    temp.pop_back();
  }
  mx[x] = max(mx[x], a[ind]);
  if ((int)dq[x].size() > SQ * 2) {
    int y = x;
    while ((int)dq[x].size() > SQ * 2) {
      while ((int)dq[x].size() > SQ) {
        int u = dq[x].back();
        dq[x].pop_back();
        dq[x + 1].push_front(u);
        mx[x + 1] = max(mx[x], u);
      }
      x++;
    }
    for (; y <= x; y++) {
      mx[y] = 0;
      for (int i = 0; i < (int)dq[y].size(); i++) mx[y] = max(mx[y], dq[y][i]);
    }
  }
  lst = max(lst, x);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> c[i];
    wh[a[i]] = i + 1;
  }
  for (int i = 0; i < n; i++) add(i);
  for (int i = 0; i < lst + 1; i++) {
    for (int j = 0; j < (int)dq[i].size(); j++) cout << wh[dq[i][j]] << " ";
  }
  cout << endl;
  return 0;
}
