loop do
   n = gets.to_i
   break if n == 0
   million_over = []
   n.times do |i|
      member = gets.split(" ").map{|x|x.to_i}
      million_over.push member[0] if member[1] * member[2] >= 1_000_000
   end
   if million_over.length == 0
      puts "NA"
   else
      million_over.each do |id|
         puts id
      end
   end
end