n = gets.chomp.to_i
arr = []
(1..n).each do |i|
    x = []
    a,b = gets.chomp.split(" ")
    b = b.to_i
    x << a
    x << b
    x << i
    arr << x
end
 arr.sort_by!{|x| [x[0],-x[1]]}

arr.each do |i|
    puts i[-1]
end

    
# end
# ar = []