const main = (input) => {
  var N = input.split("\n")[0]-0;
  var lists = [];
  for(var i=1;i<=N;i++){
    var s = input.split("\n")[i].split(" ")[0];
    var p = input.split("\n")[i].split(" ")[1]-0;
    lists.push({idx:i, s:s, p:p});
  }
  lists.sort((a,b)=>{
    if(a.s == b.s){
      return b.p-a.p;
    }else{
      if(a.s>b.s) return 1;
      else return -1;
    }
  });
  lists.forEach(v=>console.log(v.idx));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
