while True:
    num = 0
    n = int(input())
    E_lis = []
    pri_lis = []
    if n == 0:
        break
    for i in range(n):
        e,p,q = map(int,input().split())
        if e in E_lis:
            pri_lis[E_lis.index(e)] += p*q
        else:
            E_lis.append(e)
            pri_lis.append(p * q)
    for j in range(len(E_lis)):
        if pri_lis[j] >= 1000000:
            print(E_lis[j])
            num += 1
    if num == 0:
        print("NA")