#include <bits/stdc++.h>
#pragma GCC optimize(Ofast)
using namespace std;
vector<vector<int> > a;
vector<int> Max, b, c;
int i, j, n, x, y, k, f, f2;
void balance(int kol) {
  c.clear();
  int x = kol / a.size() + 1;
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a[i].size(); j++) c.push_back(a[i][j]);
  int j = 0;
  a.clear();
  Max.clear();
  a.resize(k);
  Max.assign(k, 0);
  for (int i = 0; i < c.size(); i++) {
    if ((i + 1) % x == 0) j++;
    a[j].push_back(c[i]);
    Max[j] = max(c[i], Max[j]);
  }
}
int main() {
  cin >> n;
  k = sqrt(n) + 1;
  a.resize(k);
  Max.resize(k);
  b.resize(n + 1);
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    b[x] = i + 1;
    for (j = a.size() - 1; j >= 0; j--) {
      if (j > 0 && Max[j] < x && a[j].size() < y)
        y -= a[j].size();
      else {
        f = j;
        break;
      }
    }
    f2 = a[f].size();
    a[f].push_back(x);
    while (f2 > 0 && a[f][f2] > a[f][f2 - 1] && y > 0) {
      y--;
      swap(a[f][f2], a[f][f2 - 1]);
      f2--;
    }
    Max[f] = max(Max[f], x);
    if (i % (k - 1) == 0) balance(i + 1);
  }
  for (i = 0; i < a.size(); i++)
    for (j = 0; j < a[i].size(); j++) cout << b[a[i][j]] << ' ';
  return 0;
}
