n = gets.to_i
restrant = {}
n.times do |i|
 city, score = gets.chomp.split(" ")
 if  restrant[city] == nil
   restrant[city] = []
 end
 restrant[city].push([score.to_i, i+1])
end


for city, scores in  restrant.sort{|k, v| k<=>v}
  for score in scores.sort.reverse{|s, n| s<=>n}
    puts score[1]
  end
end