require 'scanf'
while str = STDIN.gets
    n = str.to_i
    exit 0 if n==0
    hash = Hash.new
    idlist = Array.new
    for i in 0..n-1 do
        #id tanka num
        list = STDIN.gets.scanf("%d %d %d")
        money = list[1] * list[2]
        id = list[0]
        if not hash.has_key?id then
            hash[id] = 0
            idlist.push id
        end
        hash[id] = hash[id] + money
    end
    flag = true
    for i in idlist do
        if hash[i] >= 1000000 then
            print i,"\n" 
            flag = false
        end
    end
    print "NA\n" if flag
end