while True:
    n = int(input())
    if n == 0:
        break
    flag = False
    dic = {}
    for j in range(n):
        i,p,q = map(int, input().split())
        if i not in dic:
            dic[i] = [p*q, 0]
        else:
            dic[i][0] += p*q
        
        if dic[i][0] >= 10**6 and dic[i][1] == 0:
            print(i)
            dic[i][1] = 1
            flag = True
    if flag == False:
        print("NA")