#include <bits/stdc++.h>
using namespace std;
signed main() {
  long N;
  cin >> N;
  vector<tuple<string, long, long>> a(N);
  for (long i = 0; i < N; i++) {
    string s;
    long n;
    cin >> s >> n;
    a[i] = {s, -n, i + 1};
  }
  sort(a.begin(), a.end());
  for (long i = 0; i < N; i++) {
    cout << get<2>(a[i]) << endl;
    ;
  }
}
