n = gets.to_i

sp = []
n.times do |i|
  sp << [i + 1] + gets.strip.split(" ")
end

sp.sort! do |a, b|
  if a[1] != b[1]
    a[1] <=> b[1]
  else
    -a.last.to_i <=> -b.last.to_i
  end
end

sp.each do |t|
  puts t.first
end

