#include <bits/stdc++.h>
int main() {
  int n, Box;
  scanf("%d", &n);
  int p[n + 1];
  int poi[n + 1];
  char s[n + 1][11], box[11];
  for (int i = 1; i <= n; i++) {
    scanf("%s %d", s[i], &p[i]);
    poi[i] = i;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= n; j++) {
      if (strcmp(s[j - 1], s[j]) > 0) {
        strcpy(box, s[j - 1]);
        strcpy(s[j - 1], s[j]);
        strcpy(s[j], box);
        Box = poi[j - 1];
        poi[j - 1] = poi[j];
        poi[j] = Box;
      }
      if (strcmp(s[j - 1], s[j]) == 0) {
        if (p[j] > p[j - 1]) {
          Box = poi[j];
          poi[j] = poi[j - 1];
          poi[j - 1] = Box;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", poi[i]);
  }
  return 0;
}
