#include <bits/stdc++.h>
using namespace std;
struct Node {
  Node *left, *right;
  int y, sub_size, num, prior, mx_prior;
  Node(int x, int a, int _y = rand()) {
    mx_prior = prior = a;
    num = x, y = _y;
    sub_size = 1;
    left = right = nullptr;
  }
};
int get_size(Node* n) {
  if (n == nullptr) {
    return 0;
  }
  return n->sub_size;
}
int get_mx_prior(Node* n) {
  if (n == nullptr) {
    return -10;
  }
  return n->mx_prior;
}
Node* validate(Node* root) {
  if (root == nullptr) {
    return root;
  }
  root->sub_size = 1 + get_size(root->left) + get_size(root->right);
  root->mx_prior = max(
      root->prior, max(get_mx_prior(root->left), get_mx_prior(root->right)));
  return root;
}
pair<Node*, Node*> split(Node* root, int x) {
  pair<Node*, Node*> res = {nullptr, nullptr};
  if (root == nullptr) {
    return res;
  }
  if (get_size(root->left) < x) {
    res = split(root->right, x - get_size(root->left) - 1);
    root->right = validate(res.first);
    res.first = validate(root);
  } else {
    res = split(root->left, x);
    root->left = validate(res.second);
    res.second = validate(root);
  }
  return res;
}
Node* merge(Node* l, Node* r) {
  if (l == nullptr) {
    return r;
  }
  if (r == nullptr) {
    return l;
  }
  if (l->y > r->y) {
    l->right = merge(l->right, r);
    return validate(l);
  }
  r->left = merge(l, r->left);
  return validate(r);
}
void dfs(Node* root) {
  if (root == nullptr) {
    return;
  }
  dfs(root->left);
  cout << root->num << " ";
  dfs(root->right);
}
void dfs_pri(Node* root) {
  if (root == nullptr) {
    return;
  }
  dfs_pri(root->left);
  cout << root->prior << " ";
  dfs_pri(root->right);
}
Node* add(Node* root, int num, int a) { return merge(root, new Node(num, a)); }
int get_max(Node* root, int l, int r) {
  auto [left, tmp] = split(root, l);
  auto [mid, right] = split(tmp, r - l + 1);
  auto res = get_mx_prior(mid);
  root = merge(left, merge(mid, right));
  return res;
}
int main() {
  cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  Node* root = nullptr;
  for (int i = 0; i < n; ++i) {
    int a, c;
    cin >> a >> c;
    int l = 0, r = c + 1;
    while (r - l > 1) {
      int md = (l + r) / 2;
      int lh = i - md, rh = i - 1;
      if (get_max(root, lh, rh) < a) {
        l = md;
      } else {
        r = md;
      }
    }
    int j = i - l;
    auto [left, right] = split(root, j);
    left = add(left, i + 1, a);
    root = merge(left, right);
  }
  dfs(root);
  return 0;
}
