"use strict"

function main(input) {
  let dataList = input.split("\n");
  dataList.shift();
  dataList.pop();
  let items = dataList.map((data, index) => {
    const tmp = data.split(" ")
    return { index: index + 1, city: tmp[0], point: parseInt(tmp[1]) }
  });
  items.sort(function(a, b) {
    if (a.city < b.city) return -1
    if (a.city > b.city) return 1
    if (a.point < b.point) return 1
    if (a.point > b.point) return -1
  })
  items.forEach(item => {
    console.log(item.index);
  })
} 

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