'use strict'
 
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  const targets = [];
  const result = [];
  
  for(let i = 0; i<input.length; i++){
    if(i === 0) continue
    const line = input[i].split(" ");
    targets.push({name: line[0], score: parseInt(line[1], 10)});
  }
  
  targets.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 j = 0; j < targets.length; j++){
  	for(let k = 0; k < input.length; k++){
	  if(k===0) continue;
      const line = input[k].split(" ");
      if(line[0] === targets[j].name && parseInt(line[1], 10) === targets[j].score){
        result.push(k)
      }
    }
  }
  
  for(let l = 0; l < result.length; l++){
  	console.log(result[l]);
  }
 
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));