while line = gets do
  return if line.chomp == 0

  n = line.chomp.to_i

  n.times do
    l = gets.chomp.split(' ')
    i = l[0]
    p = l[1]
    q = l[2]

    if p.to_i * q.to_i >= 1000000 then
      puts i.to_s + "\n"
    end
  end
end