#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  char str[11];
  int P;
  pair<pair<string, int>, int> p[N];
  for (int i = 0; i < N; i++) {
    cin >> str >> P;
    string S = str;
    p[i] = make_pair(make_pair(S, -P), i);
  }
  sort(p, p + N);
  for (int i = 0; i < N; i++) {
    cout << p[i].second + 1 << "\n";
  }
  cout << endl;
  return 0;
}
