n = gets.chomp.split[0].to_i

list = []

for i in 1..n do
    input = gets.chomp.split
    s = input[0]
    pt = input[1].to_i
    rest = [s,pt,i]
    list.push(rest)
end

list.sort! {|x,y| (x[0] <=> y[0]).nonzero? || (y[1] <=> x[1]) }

for i in 1..n do
    puts list[i-1][2]
end
