#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, a, point;
  string b;
  string city;
  cin >> N;
  vector<pair<pair<string, int>, int> > AA;
  for (int i = 0; i < N; i++) {
    cin >> b;
    cin >> a;
    AA.push_back(make_pair(make_pair(b, a * (-1)), i + 1));
  }
  sort(AA.begin(), AA.end());
  for (int i = 0; i < N; i++) cout << AA[i].second << endl;
  ;
}
