"use strict"

function main(input) {
  const lines = input.split('\n')
  lines.shift()
  lines.pop()
  let items = lines.map((data, index) => {
    const 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
    return 0
  })
  for (let v of items) {
    console.log('%d', v.no)
  }
} 
main(require('fs').readFileSync('/dev/stdin', 'utf8'))