#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int SQR = 316;
const int NRB = 330;
struct bu {
  vector<int> el;
  int smax;
  bu() { smax = 0; }
};
int n, ver[N];
bu b[NRB];
vector<int> elem;
void remake() {
  elem.clear();
  int i, j;
  for (i = 0; i < NRB; ++i) {
    for (j = 0; j < b[i].el.size(); ++j) elem.push_back(b[i].el[j]);
    b[i].el.clear();
    b[i].smax = 0;
  }
  int nrc = -1;
  for (i = 0; i < elem.size(); ++i) {
    if (i % SQR == 0) ++nrc;
    b[nrc].el.push_back(elem[i]);
    b[nrc].smax = max(b[nrc].smax, elem[i]);
  }
}
void add(int a, int c) {
  int i, j;
  for (i = NRB - 1; i >= 0; --i) {
    if (i == 0 || b[i].smax > a || (c <= b[i].el.size() && b[i].el.size())) {
      b[i].el.push_back(a);
      b[i].smax = max(b[i].smax, a);
      for (j = b[i].el.size() - 2; j >= 0; --j) {
        if (c && b[i].el[j] < b[i].el[j + 1]) {
          --c;
          swap(b[i].el[j], b[i].el[j + 1]);
        } else
          break;
      }
      break;
    }
    c -= b[i].el.size();
  }
}
int main() {
  int i, j;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    int a, c;
    cin >> a >> c;
    ver[a] = i;
    add(a, c);
    if (i % SQR == 0) remake();
  }
  for (i = 0; i < NRB; ++i)
    for (j = 0; j < b[i].el.size(); ++j) cout << ver[b[i].el[j]] << " ";
  return 0;
}
