#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, P;
  string S;
  cin >> N;
  vector<tuple<string, int, int>> V(N);
  for (int i = 0; cin >> S >> P; i++) V.at(i) = make_tuple(S, -P, i + 1);
  sort(V.begin(), V.end());
  for (auto v : V) cout << get<2>(v) << "\n";
}