"use strict"

function main(input) {
  const lines = input.split('\n')
  const n = parseInt(lines[0], 10)
  let items = []
  for (let i = 1; i<=n; i++) {
    const val = lines[i].split(' ')
    items.push({
      no: i,
      name: val[0].toLowerCase(),
      point: parseInt(val[1], 10)
    })
  }
  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
  })
  for (let v of items) {
    console.log('%d', v.no)
  }
} 
main(require('fs').readFileSync('/dev/stdin', 'utf8'))