#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  vector<pair<pair<string, int>, int>> vect(n);
  for (i = 0; i < n; i++) {
    cin >> vect[i].first.first;
    cin >> vect[i].first.second;
    vect[i].first.second *= -1;
    vect[i].second = i;
  }
  sort(vect.begin(), vect.end());
  for (i = 0; i < n; i++) {
    cout << vect[i].second + 1 << endl;
  }
  return 0;
}
