#include <bits/stdc++.h>
struct data {
  std::string S;
  int in;
  int P;
  data(std::string name, int num, int price) {
    S = name;
    in = num;
    P = price;
  }
  bool operator<(const data &another) const {
    if (S == another.S) {
      return P > another.P;
    } else {
      return S < another.S;
    }
  };
};
int main() {
  int N;
  std::vector<data> Data;
  int P1;
  std::string S1;
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> S1;
    std::cin >> P1;
    Data.push_back(data(S1, i, P1));
  }
  std::sort(Data.begin(), Data.end());
  for (int i = 0; i < N; i++) {
    std::cout << (Data[i].in) + 1 << std::endl;
  }
  return 0;
}
