#include <bits/stdc++.h>
struct shop {
  int p;
  int index;
  char s[20];
};
int main(void) {
  int n, ret;
  ret = scanf("%d", &n);
  struct shop shops[n], tmp;
  for (int i = 0; i < n; i++) {
    ret = scanf("%s %d", shops[i].s, &shops[i].p);
    shops[i].index = i;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (strcmp(shops[i].s, shops[j].s) > 0) {
        tmp = shops[i];
        shops[i] = shops[j];
        shops[j] = tmp;
      } else if (strcmp(shops[i].s, shops[j].s) == 0) {
        if (shops[i].p < shops[j].p) {
          tmp = shops[i];
          shops[i] = shops[j];
          shops[j] = tmp;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", shops[i].index);
  }
  return 0;
}
