#include <bits/stdc++.h>
using namespace std;
const int inf = 10000000;
struct vertex {
  vector<int> v;
  int max;
  vertex *n;
};
vertex *tail;
int n, sqrn;
int num[100001];
void push(int a, int c) {
  vertex *tmp;
  tmp = tail;
  while (tmp->max < a && tmp->v.size() < c) {
    c -= tmp->v.size();
    tmp = tmp->n;
  }
  vector<int>::iterator it = tmp->v.begin();
  for (; c > 0 && (*it) < a; c--, it++)
    ;
  tmp->v.insert(it, a);
  tmp->max = max(tmp->max, a);
  if (tmp->v.size() > sqrn) {
    vertex *newv;
    newv = new vertex;
    newv->n = tmp->n;
    tmp->n = newv;
    newv->v.insert(newv->v.begin(), tmp->v.begin() + sqrn, tmp->v.end());
    newv->max = *max_element(newv->v.begin(), newv->v.end());
    tmp->v.erase(tmp->v.begin() + sqrn);
    tmp->max = *max_element(tmp->v.begin(), tmp->v.end());
  }
}
vector<int> res;
void vuvid() {
  vertex *t = tail;
  res.clear();
  while (t != NULL) {
    res.insert(res.end(), t->v.begin(), t->v.end());
    t = t->n;
  }
  res.pop_back();
  reverse(res.begin(), res.end());
  for (vector<int>::iterator it = res.begin(); it != res.end(); it++)
    printf("%d ", num[*it]);
  printf("\n");
}
int main() {
  tail = new vertex;
  tail->max = inf;
  tail->n = NULL;
  tail->v.push_back(inf);
  scanf("%d", &n);
  sqrn = floor(sqrt((double)n) + 0.5);
  int a, c;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &c);
    push(a, c);
    num[a] = i + 1;
  }
  res.clear();
  while (tail != NULL) {
    res.insert(res.end(), tail->v.begin(), tail->v.end());
    tail = tail->n;
  }
  res.pop_back();
  reverse(res.begin(), res.end());
  for (vector<int>::iterator it = res.begin(); it != res.end(); it++)
    printf("%d ", num[*it]);
  printf("\n");
  return 0;
}
