#include <bits/stdc++.h>
using std::advance;
using std::list;
using std::max;
using std::vector;
class Block {
 public:
  Block();
  int GetSize() const;
  bool MustBeHere(int a, int c) const;
  void Insert(int a, int c);
  void ExtractFirst(int block_size, Block &b);
  void GetData(int *buffer) const;

 private:
  int GetMax() const;
  list<int> list_;
  int max_, size_;
};
Block::Block() : size_(0) {}
inline int Block::GetSize() const { return size_; }
bool Block::MustBeHere(int a, int c) const {
  return GetSize() > c || GetMax() > a;
}
void Block::Insert(int a, int c) {
  list<int>::iterator it = list_.begin();
  while (it != list_.end() && c != 0 && *it <= a) {
    --c;
    ++it;
  }
  list_.insert(it, a);
  ++size_;
  max_ = max(max_, a);
}
void Block::GetData(int *buffer) const {
  list<int>::const_iterator it = list_.end();
  while (it != list_.begin()) *buffer++ = *--it;
}
void Block::ExtractFirst(int block_size, Block &b) {
  b.list_.clear();
  list<int>::iterator from = list_.begin(), to = from;
  advance(to, block_size);
  b.list_.splice(b.list_.begin(), list_, from, to);
  b.max_ = *max_element(b.list_.begin(), b.list_.end());
  b.size_ = block_size;
  max_ = *max_element(list_.begin(), list_.end());
  size_ -= block_size;
}
int Block::GetMax() const { return max_; }
const int kPeople = 100000;
int n, a[kPeople], c[kPeople], order[kPeople], back[kPeople + 1];
list<Block> blocks;
void ReadData() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i], &c[i]);
    back[a[i]] = i;
  }
}
int CeilSqrt(int n) {
  int result = 1;
  while (result * result < n) ++result;
  return result;
}
void Insert(int a, int c, int block_size) {
  list<Block>::iterator it = --blocks.end();
  while (it != blocks.begin() && !it->MustBeHere(a, c)) {
    c -= it->GetSize();
    --it;
  }
  it->Insert(a, c);
  if (it->GetSize() == 2 * block_size) {
    list<Block>::iterator next = it;
    ++next;
    list<Block>::iterator inserted = blocks.insert(next, Block());
    it->ExtractFirst(block_size, *inserted);
  }
}
void Solve() {
  int block_size = CeilSqrt(n);
  blocks.push_back(Block());
  for (int i = 0; i < n; ++i) Insert(a[i], c[i], block_size);
  int *cur = order;
  for (list<Block>::const_iterator it = blocks.begin(); it != blocks.end();
       ++it) {
    it->GetData(cur);
    cur += it->GetSize();
  }
}
void WriteData() {
  for (int i = 0; i < n; ++i) printf("%d ", back[order[i]] + 1);
  printf("\n");
}
int main() {
  ReadData();
  Solve();
  WriteData();
  return 0;
}
