#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  string s[n];
  int p[n];
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> p[i];
    a[i] = i;
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int k = a[i];
      int l = a[j];
      if (s[k] > s[l]) {
        a[i] = l;
        a[j] = k;
      }
      if (s[k] == s[l] && p[k] < p[l]) {
        a[i] = l;
        a[j] = k;
      }
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << a[i] + 1 << endl;
  }
  cout << a[n - 1] + 1;
  return 0;
}
