function Main(input) {
    var result;
    const N = parseInt(input.shift());
    const SP = [];
    for (var i = 0; i < N; i++) {
        SP.push({
            I: i+1,
            S: input[i*2],
            P: parseInt(input[i*2+1])
        })
    }
    
    SP.sort((a,b) => {
        var stComp = a.S.localeCompare(b.S);
        if(stComp == 0) {
            return -a.P + b.P;
        }
        return stComp;
    })
    SP.forEach(value => console.log(value.I));
}

// 1行入力の場合
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

// 改行で分割
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));