'use strict'
function Main(input) {
    input = input.trim().split(/\n/)
    input.shift()
    input = input.map(elem => {
      return elem.split(' ')
    })

    input = input.map((elem, index) => {
      let newElem = []
      newElem[0] = index+1
      newElem[1] = elem[0]
      newElem[2] = parseInt(elem[1])
      return newElem
    })
  
    input.sort((a, b) => {
      if(a[1] !== b[1]) {
        return a[1] > b[1]
      } else{
        return a[2] < b[2]
      }
    })

    input.forEach(elem => {
      console.log(elem[0])
    })

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))