while true do
  n = gets.chomp.to_i
  break if n == 0
  array = []
  n.times do
    ar = gets.chomp.split(" ").map(&:to_i)
    ar << ar[1] * ar[2]
    array << ar
  end
  numbers = array.select{|ar| ar[3] >= 1000000}
  if numbers.length > 0
    str = ""
    numbers.each do |number|
      str << number.to_s + " "
    end
    puts str.chop
  else
    puts "NA"
  end
end