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