N = gets.chomp.to_i
# A, P = gets.chomp.split.map(&:to_i)
# A = Array.new(N + 1, 0)  # 0 means no trap, 1 means existence of trap. 1-indexed

pairs = []
N.times do |i|
  s, p = gets.chomp.split
  pairs << [s, p.to_i, i]
end

pairs.sort_by { |(s, p, i)| [s, - p] }.each do |(s, p, i)| 
  p i + 1
end