#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5, SQRT = 353;
int n;
vector<int> seg[SQRT];
int maxi[SQRT];
int ans[MAX_N];
int Arr[MAX_N];
void shift(int ind, int val) {
  for (int i = 1; i <= val; i++)
    swap(seg[ind][seg[ind].size() - i], seg[ind][seg[ind].size() - i - 1]);
}
void Add(int ind, int a, int p) {
  int tmp = -1;
  for (int i = 0; i < min(p, (int)seg[ind].size()); i++) {
    if (a < seg[ind][i]) break;
    tmp = i;
  }
  maxi[ind] = max(maxi[ind], a);
  seg[ind].push_back(a);
  shift(ind, seg[ind].size() - tmp - 2);
}
void relax() {
  memset(maxi, 0, sizeof maxi);
  int Ind = 0;
  for (int i = 0; i < SQRT; i++) {
    for (int j = 0; j < seg[i].size(); j++) Arr[Ind++] = seg[i][j];
    seg[i].clear();
  }
  for (int i = 0; i < Ind; i++) {
    seg[i / SQRT].push_back(Arr[i]);
    maxi[i / SQRT] = max(maxi[i / SQRT], Arr[i]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    if (i % SQRT == 0) relax();
    int a, c, tmp = 0;
    scanf("%d %d", &a, &c);
    ans[a] = i + 1;
    for (int j = 0; j < SQRT; j++) {
      if (a < maxi[j] || c < tmp + seg[j].size() || j + 1 == SQRT) {
        tmp = (int)c - (int)tmp;
        Add(j, a, tmp);
        break;
      }
      tmp += (int)seg[j].size();
    }
  }
  for (int i = SQRT - 1; ~i; i--)
    for (int j = seg[i].size() - 1; ~j; j--) printf("%d ", ans[seg[i][j]]);
  return 0;
}
