#include <bits/stdc++.h>
typedef struct restaurant {
  char name[11];
  int P;
  int num;
} restaurant;
int compare_string(const void *a, const void *b) {
  return strcmp(((struct restaurant *)a)->name, ((struct restaurant *)b)->name);
}
int compare_int(const void *a, const void *b) {
  return ((struct restaurant *)b)->P - ((struct restaurant *)a)->P;
}
int main() {
  int N;
  scanf("%d", &N);
  restaurant S[N];
  for (int i = 0; i < N; i++) {
    scanf("%s %d", &S[i].name[0], &S[i].P);
    S[i].num = i + 1;
  }
  qsort(S, N, sizeof(struct restaurant), compare_string);
  int same[N], cnt = 0;
  for (int i = 0; i < N; i++) {
    same[i] = 0;
  }
  same[0] = 1;
  for (int i = 0; i < N - 1; i++) {
    if (strcmp(S[i].name, S[i + 1].name) == 0) {
      same[cnt] += 1;
    } else {
      cnt++;
      same[cnt] += 1;
    }
  }
  int ans[N];
  int point = 0;
  for (int i = 0; same[i] != 0; i++) {
    restaurant block[same[i]];
    for (int j = 0; j < same[i]; j++) {
      strcpy(block[j].name, S[point + j].name);
      block[j].P = S[point + j].P;
      block[j].num = S[point + j].num;
    }
    qsort(block, same[i], sizeof(struct restaurant), compare_int);
    for (int j = 0; j < same[i]; j++) {
      ans[point + j] = block[j].num;
    }
    point += same[i];
  }
  for (int i = 0; i < N; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
