#include <bits/stdc++.h>
int main() {
  int a, i, j, n;
  scanf("%d", &n);
  char c[10][n], temp1[10];
  int p[n];
  int jun[n], temp;
  for (i = 0; i < n; i++) {
    scanf("%s %d", c[i], &p[i]);
    jun[i] = i + 1;
  }
  for (j = 1; j < n; j++) {
    for (i = 1; i < n; i++) {
      if (strcmp(c[i - 1], c[i]) > 0) {
        strcpy(temp1, c[i]);
        strcpy(c[i], c[i - 1]);
        strcpy(c[i - 1], temp1);
        temp = p[i];
        p[i] = p[i - 1];
        p[i - 1] = temp;
        temp = jun[i];
        jun[i] = jun[i - 1];
        jun[i - 1] = temp;
      } else if (c[i - 1] == c[i]) {
        if (p[i - 1] < p[i]) {
          temp = p[i];
          p[i] = p[i - 1];
          p[i - 1] = temp;
          temp = jun[i];
          jun[i] = jun[i - 1];
          jun[i - 1] = temp;
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    printf("%d\n", jun[i]);
  }
  return 0;
}
