#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 9, B = 300;
long long a[N], b[N], mx[N], id[N];
vector<long long> v[N];
void ADD(long long ind) {
  long long pos = ind / B;
  while (pos > 0 && mx[pos] <= a[ind] && b[ind] - v[pos].size() >= 0)
    b[ind] -= v[pos].size(), pos--;
  long long i = v[pos].size();
  v[pos].push_back(a[ind]);
  mx[pos] = max(mx[pos], a[ind]);
  while (i > 0 && v[pos][i] > v[pos][i - 1] && b[ind] > 0)
    b[ind]--, swap(v[pos][i], v[pos][i - 1]), i--;
}
void CLEAN() {
  vector<long long> vec;
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < v[i].size(); j++) vec.push_back(v[i][j]);
  for (long long i = 0; i < N; i++) v[i].clear(), mx[i] = 0;
  for (long long i = 0; i < vec.size(); i++)
    v[i / B].push_back(vec[i]), mx[i / B] = max(mx[i / B], vec[i]);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    if (i % B == 0) CLEAN();
    cin >> a[i] >> b[i];
    id[a[i]] = i + 1;
    ADD(i);
  }
  for (long long i = 0; i < N; i++)
    for (long long x : v[i]) cout << id[x] << " ";
  return 0;
}
