#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int SQ = 350;
const int maxS = (N / SQ);
struct man {
  int index, imp;
  man(int _i = -1, int _imp = -1) {
    index = _i;
    imp = _imp;
  }
};
int n, max_imp[SQ + 10];
vector<man> gr[SQ + 10];
void relax();
void build();
void insert(int, int, int);
void add_to(int, int, int, int);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  build();
  for (int i = 0; i < n; i++) {
    int imp, k;
    cin >> imp >> k;
    insert(imp, k, i);
    if ((i + 1) % maxS == 0) relax();
  }
  for (int i = 0; i < SQ; i++)
    for (man j : gr[i]) cout << j.index + 1 << ' ';
  cout << endl;
}
void build() {
  for (int i = 0; i < SQ + 2; i++) {
    gr[i].clear();
    max_imp[i] = -1;
  }
}
void insert(int imp, int con, int ind) {
  int i = SQ - 1;
  for (; i > 0; i--)
    if (gr[i].size() > 0) break;
  for (; i > 0; i--) {
    if ((gr[i].size() >= con) || (max_imp[i] >= imp)) {
      add_to(i, imp, con, ind);
      break;
    }
    con -= gr[i].size();
  }
  if (i == 0) add_to(0, imp, con, ind);
}
void add_to(int t, int imp, int con, int ind) {
  max_imp[t] = max(max_imp[t], imp);
  gr[t].push_back(man(ind, imp));
  int i = gr[t].size() - 1;
  while ((con > 0) && (i > 0) && (gr[t][i].imp > gr[t][i - 1].imp)) {
    swap(gr[t][i], gr[t][i - 1]);
    con--;
    i--;
  }
}
void relax() {
  vector<man> data;
  for (int i = 0; i < SQ; i++)
    for (man j : gr[i]) data.push_back(j);
  build();
  int cur = 0;
  for (man i : data) {
    gr[cur].push_back(i);
    if (gr[cur].size() == maxS) {
      max_imp[cur] = -1;
      for (man j : gr[cur]) max_imp[cur] = max(max_imp[cur], j.imp);
      cur++;
    }
  }
}
