'use strict'

// 比較関数の作成
function compare(a,b) {
  let r = 0;

  if(a.city < b.city){
  r = -1;
  }
  else if(a.city > b.city){
    r = 1;
  }
  else if(a.point < b.point){
  r = 1;
  }
  else if(a.point > b.point){
  r = -1;
  }
  return r;
}
function Main(input) {
  let x = input.split('\n');
  let N = x.shift();
  let array = [];
  for(let i = 0; i < N; i++){
  let tmp = x[i].split(' ');
   	array.push({id:i+1, city:tmp[0], point:parseInt(tmp[1])}) 
  }
  array.sort(compare);
  array.forEach(element=>{
    console.log(element.id);
  });
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
