while True:
    n = int(raw_input())
    if n == 0:
        break
    data = []
    for i in range(n):
        n, p, s = map(int, raw_input().split())
        if data.count(n) == 0:
            data.append([n,p*s])
        else:
            data[data.index(n)][1] += p*s
            
    data.sort()
    flag = 0
    for i in data:
        if i[1] >= 1000000:
            print i[0]
            flag = 1
    if flag == 0:
        print "NA"
        