function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var len = parseInt(input[0]);
  var list = [];
  for(var i = 1; i <= len; i++){
    var name = input[i].split(" ")[0];
    var point = parseInt(input[i].split(" ")[1]);
    var obj = {
      "no" : i,
      "name" : name,
      "point" : point
    };
    list.push(obj);
  }
  list.sort(function(a,b){
  	if(a["name"] == b["name"]){
       return b["point"] - a["point"];
    }else{
    	if(a["name"] < b["name"]){
       return -1;
        }else{
          return 1;
        }
    }
  });
  
  for(var i = 0; i < len; i++){
    myout(list[i]["no"]);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
