function main(input) {
  // 入力値取得
  const inputValue = input.split(/\n/);
  const numOfRestaurant = formatNum(inputValue[0]);
  const restaurantInfo = inputValue
  	.filter((v, i) => i > 0)
  	.map((iv, index) => {
      const info = iv.split(/\s/);
      return {
        name: info[0],
        point: formatNum(info[1]),
        index: index + 1
      };
    });
  // 評価順に並べた後に店名順に並べる
  restaurantInfo.sort((a, b) => {
    if (a.point > b.point) {
      return -1;
    }
    return 1;
  }).sort((c, d) => {
    if (c.name > d.name) {
      return 1;
    }
    return -1;
  });
  restaurantInfo.forEach(ri => {
    console.log(ri.index);
  });
};

// 文字列を数値に変換
function formatNum(str) {
  return Number(str);
};

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