#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a;
  for (int i = 0; i < N; i++) {
    string x;
    int b;
    cin >> x >> b;
    a.push_back(make_tuple(x, -b, i + 1));
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    cout << get<2>(a.at(i)) << endl;
  }
}
