n=gets.to_i
book=Array.new(n).map{Hash.new}
n.times do |i|
    book[i][:id]=i+1
    s=gets.split
    book[i][:name]=s[0]
    book[i][:price]=s[1].to_i
end
book.sort_by!{|book| [book[:name], -book[:price]]}
book.each do |book|
    puts book[:id]
end
