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