"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const SP = arg.slice(1, N + 1);
    
    let list = [];
    
    for(let i in SP) {
        const S = SP[i].split(" ")[0];
        const P = SP[i].split(" ")[1];
        
        const temp = {name: S, point: P, originIdx: i};
        
        list.push(temp);
    }
    
    list.sort((a,b)=>{
        if(a.name < b.name) {
            return -1;
        }
        
        if(a.name > b.name) {
            return 1;
        }
        
        if(a.point - b.point > 0) {
            return -1;
        }
        
        if(a.point - b.point < 0) {
            return 1;
        }
        
        return 0;
    });
    
    // list.sort((a,b)=>a.name < b.name);
    // console.log(JSON.stringify(list));
    
    let answer = [];
    
    for(let i in list) {
        answer.push(parseInt(list[i].originIdx) + 1);
    }
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));