#!/usr/bin/ruby

until (n = gets.to_i).zero?
  data = {}
  data.default = 0

  n.times do
    input = gets.split.map(&:to_i)

    data[input[0]] += input[1] * input[2]
  end

  keys = data.select{|k, v| v >= 1000000 }.keys.join(?\n)

  if keys.empty?
    puts "NA"
  else
    puts keys
  end
end