#include <bits/stdc++.h>
using namespace std;
struct Treap;
int siz(Treap* A);
void recalc(Treap* A);
struct Treap {
  int y;
  int val;
  int max;
  int x;
  int ind;
  Treap* L = nullptr;
  Treap* R = nullptr;
  Treap(int a, int i) {
    x = 1;
    y = 1ll * rand() * rand() % int(1e9);
    max = val = a;
    ind = i;
  }
};
Treap* merge(Treap* A, Treap* B) {
  if (A == nullptr) {
    return B;
  }
  if (B == nullptr) {
    return A;
  }
  recalc(A);
  recalc(B);
  if (A->y > B->y) {
    A->R = merge(A->R, B);
    recalc(A);
    return A;
  } else {
    B->L = merge(A, B->L);
    recalc(B);
    return B;
  }
}
pair<Treap*, Treap*> split(Treap* A, int k) {
  recalc(A);
  if (A == nullptr) {
    return {nullptr, nullptr};
  }
  if (siz(A->L) >= k) {
    auto tmp = split(A->L, k);
    A->L = tmp.second;
    recalc(A);
    return {tmp.first, A};
  } else {
    auto tmp = split(A->R, k - siz(A->L) - 1);
    A->R = tmp.first;
    recalc(A);
    return {A, tmp.second};
  }
}
int siz(Treap* A) { return A == nullptr ? 0 : A->x; }
void recalc(Treap* A) {
  if (A == nullptr) {
    return;
  }
  A->x = siz(A->L) + siz(A->R) + 1;
  A->max = A->val;
  if (A->L != nullptr) {
    A->max = max(A->max, A->L->max);
  }
  if (A->R != nullptr) {
    A->max = max(A->max, A->R->max);
  }
}
void clear(Treap* A) {
  if (A == nullptr) {
    return;
  }
  clear(A->L);
  clear(A->R);
  delete A;
}
int find(Treap* A, int a, int c) {
  if (c == 0 || A == nullptr) {
    return 0;
  }
  if (A->max < a) {
    return min(siz(A), c);
  }
  if (A->L != nullptr && A->L->max > a) {
    return find(A->L, a, c);
  }
  if (c <= siz(A->L)) {
    return c;
  }
  if (A->val > a) {
    return siz(A->L);
  }
  return siz(A->L) + 1 + find(A->R, a, c - siz(A->L) - 1);
}
void print(Treap* A, vector<int>& v) {
  if (A == nullptr) {
    return;
  }
  print(A->L, v);
  v.push_back(A->ind + 1);
  print(A->R, v);
}
int main() {
  int n;
  cin >> n;
  struct Treap* root = nullptr;
  for (int i = 0; i < n; ++i) {
    int a, c;
    cin >> a >> c;
    int k = find(root, a, c);
    auto tmp1 = split(root, k);
    tmp1.first = merge(tmp1.first, new Treap(a, i));
    root = merge(tmp1.first, tmp1.second);
  }
  vector<int> v;
  print(root, v);
  reverse(v.begin(), v.end());
  for (auto x : v) {
    cout << x << ' ';
  }
  cout << '\n';
  clear(root);
}
