N = gets.to_i

res = Array.new
N.times do |i|
	city, score = gets.split(' ')
	res.push([city, score.to_i, i+1])
end

res.sort!{|a,b| a[0]==b[0] ? b[1]<=>a[1] : a[0]<=>b[0]}

N.times do |j|
	puts res[j][2]
end