while (num = gets.chomp.to_i) != 0
  hash = Hash[*(1..4000).to_a.zip(Array.new(4000).fill(0)).flatten]
  num.times do
    line = gets.split.map(&:to_i)
    hash[line[0]] += (line[1] * line[2])
  end
  hash.delete_if {|k, v| v < 1000000}
  puts hash == {} ? "NA" : hash.keys
end