"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N = parseInt(arg[0]);
    const AP = arg.slice(1, N + 1);
    
    const shop = [];
    
    for(let i in AP) {
        let n  = AP[i].split(" ")[0];
        let s  = parseInt(AP[i].split(" ")[1]);

        const temp = {name: n, score: s, originIdx: parseInt(i)};
        shop.push(temp);
    }
    
    shop.sort((a,b)=>{
        if(a.name < b.name) {
            return -1;
        }
        
        if(a.name > b.name) {
            return 1;
        }
        
        if(a.score > b.score) {
            return -1;
        }
        
        if(a.score < b.score) {
            return 1;
        }
        
        return 0;
    });

    for(let i in shop) {
        console.log(shop[i].originIdx + 1);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));