n = gets.to_i
r = []
n.times do |i|
  s, p = gets.chomp.split
  r << [s, p.to_i, i + 1]
end
r.sort_by! {|s, _, _| s }
r.group_by {|s, _, _| s }.each do |_, v|
  v.sort_by! {|_, p, _| -p }
  v.each do |_, _, i|
    puts i
  end
end