function main(input) {
    var rows = input.split("\n");
    rows.shift();
    rows.map(function (r, i) {
            var c = r.split(" ");
            return {
                id: i + 1,
                name: c[0],
                score: c[1] * 1
            };
        }).sort(function (a, b) {
            if (a.name == b.name) return b.score - a.score;
            if (a.name < b.name) return -1;
            if (a.name > b.name) return 1;
            return 0;
        })
        .forEach(function (c) {
            console.log(c.id);
        });
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));