class Rest
  attr_accessor :name, :point, :num
  def initialize(num, name, point)
    @num = num
    @name = name
    @point = point
  end
end
n = gets.to_i
rests = []
n.times do |i|
  lines = gets.split
  rests.push Rest.new(i+1, lines[0], lines[1].to_i)
end
rests.sort!{|a, b| 
  if a.name != b.name
    a.name <=> b.name
  else
    b.point <=> a.point
  end
}
rests.each do |i|
  puts i.num
end