#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  pair<pair<string, int>, int> t[110];
  for (int i = 0; i < N; i++) {
    int score;
    string name;
    cin >> name >> score;
    t[i] = make_pair(make_pair(name, score * (-1)), i + 1);
  }
  std::sort(t, t + N);
  for (int i = 0; i < N; i++) {
    cout << t[i].second << endl;
  }
}
