var lines = [];

var readline = require("readline");
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on("line", function (x) {
    lines.push(x);
});

rl.on("close", function () {
    var N = Number(lines[0]); lines.shift();
    var SP = lines.map(i => i.split(" "))
    var arr = []

    for (var i = 0; i < N; i++) {
        var s = SP[i][0]; var p = SP[i][1];
        arr.push({ i: i + 1, s, p });
    }

    arr.sort((a, b) => {
        if (a.s < b.s) { return (-1); }
        else if (a.s > b.s) { return (1) }
        else { return (b.p - a.p) }
    });
    
    for (var i = 0; i < N; i++) {
        console.log(arr[i].i)
    }
});