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