while n = STDIN.gets
  n = n.chomp.to_i
  if n == 0 then break end
  ids=[]
  n.times do 
    line = STDIN.gets
    ipq = line.chomp.split(" ").map { |item| item.to_i } 
    if ipq[1]*ipq[2] >= 1000000 then
      ids.push(ipq[0])
    end
  end
  ids.each do |e|
    puts e
  end
  if ids.empty? then
    puts "NA"
  end
end