"use strict"

function main(input) {
  var dataList = input.split("\n");
  dataList.shift();
  dataList.pop();
  var items = dataList.map((data, index) => {
    var tmp = data.split(" ")
    return { no: index + 1, name: tmp[0], point: parseInt(tmp[1]) }
  });
  items.sort( function (a,b) {
    if (a.name < b.name) return -1
    if (a.name > b.name) return 1
    if (a.point < b.point) return 1
    if (a.point > b.ponit) return -1
  })
  items.forEach(item => {
    console.log(item.no)
  })
} 
main(require("fs").readFileSync("/dev/stdin", "utf8"))