#include <bits/stdc++.h>
using namespace std;

struct Node {
    string name;
    int id, score;
    operator < (const Node & a) {
        if (name == a.name) return score > a.score;
        else return name < a.name;
    }
};

int main(void) {
    Node input[105];
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        cin >> input[i].name >> input[i].score;
        input[i].id = i;
    }
    sort(input + 1, input + n + 1);
    for (int i = 1; i <= n; i++) {
        printf("%d\n", input[i].id);
    }

    return 0;
}