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