num = gets.to_i
cities = {}
num.times do |i|
  input_city_name, input_score = gets.split(" ")
  cities[input_city_name] ||= {}
  cities[input_city_name][input_score.to_i] = (i+1)
end

cities.keys.sort.each do |city_name|
  rsts = cities[city_name] 
  rsts.keys.sort.reverse.each do |score|
    puts rsts[score].to_i
  end
end