#include <bits/stdc++.h>
using namespace std;
struct pof {
  int c;
  int n;
};
vector<vector<pof> > g;
int n, sq;
vector<int> mx;
void balance() {
  vector<int> costs, numbers;
  mx.clear();
  for (int i = 0; i < g.size(); i++)
    for (int j = 0; j < g[i].size(); j++) {
      costs.push_back(g[i][j].c);
      numbers.push_back(g[i][j].n);
    }
  g.clear();
  g.push_back(vector<pof>(0));
  mx.push_back(0);
  for (int i = 0; i < costs.size(); i++) {
    pof ff;
    ff.c = costs[i];
    ff.n = numbers[i];
    g[(int)g.size() - 1].push_back(ff);
    mx[(int)mx.size() - 1] = max(mx[(int)mx.size() - 1], costs[i]);
    if ((i + 1) % sq == 0 && i != (int)costs.size() - 1) {
      g.push_back(vector<pof>(0));
      mx.push_back(0);
    }
  }
}
void ins(int x, int y, int number) {
  if (g.size() == 0) {
    g.resize(1);
    pof ff;
    ff.c = x;
    ff.n = number;
    g[0].push_back(ff);
    mx.resize(1, x);
    return;
  }
  int i, y1 = y;
  for (i = (int)g.size() - 1; i >= 0; i--) {
    if (mx[i] >= x) break;
    if (y >= g[i].size())
      y -= g[i].size();
    else
      break;
  }
  if (i == -1) y += g[0].size();
  i = max(i, 0);
  int j;
  pof ff;
  ff.c = 0;
  ff.n = 0;
  g[i].push_back(ff);
  for (j = (int)g[i].size() - 2; j >= 0; j--) {
    if (g[i][j].c >= x) break;
    y--;
    if (y < 0) break;
    g[i][j + 1].c = g[i][j].c;
    g[i][j + 1].n = g[i][j].n;
  }
  j++;
  g[i][j].c = x;
  g[i][j].n = number;
  mx[i] = max(mx[i], x);
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  sq = (int)(sqrt(n));
  for (int i = 1; i <= n; i++) {
    int xx, yy;
    cin >> xx >> yy;
    ins(xx, yy, i);
    if ((i - 1) % sq == 0) balance();
  }
  for (int i = 0; i < g.size(); i++)
    for (int j = 0; j < g[i].size(); j++) cout << g[i][j].n << ' ';
  return 0;
}
