input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1

arr = []
for (i=0; i<N; i++) {
  l = lines[i].split(' ')
  c = l[0]
  s = l[1] * 1
  arr.push({c:c, s:s, i: i+1})
}

arr.sort((a, b) => {
   if (a.c == b.c) {
       return b.s - a.s
   } else {
       return a.c < b.c ? -1 : 1
   }
})

arr.forEach((a) => {
    console.log(a.i)
}) 
