function Main(input) {

  var input = input.split("\n");
  var n = input[0];
  var sp = new Array();


  for(var i=1; i<=n;i++){
    var spa = input[i].split(" ");
    sp.push({id:i, city:spa[0], rate:spa[1]});
  }

  sp.sort((a, b) => {
    if (a.city < b.city) return -1;
    if (a.city > b.city) return 1;
    if (a.rate > b.rate) return -1;
    if (a.rate < b.rate) return 1;
    return 0;
  });
  sp.forEach(function(e, i) {
    console.log(sp[i]["id"]);
  });

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