'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.value < b.value ){ r = 1; }
  else if( a.value > b.value ){ r = -1; }

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