#include <bits/stdc++.h>
int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::pair<std::pair<std::string, int>, int> restaurant[N];
  for (int i = 0; i < N; ++i) {
    int t;
    std::string temp;
    std::cin >> temp >> t;
    restaurant[i] = std::make_pair(std::make_pair(temp, -t), i);
  }
  std::sort(restaurant, restaurant + N);
  for (int i = 0; i < N; ++i)
    std::cout << restaurant[i].second + 1 << std::endl;
  return 0;
}
