while True:
    n = int(input())
    if n == 0:
        break

    lst = [0]*4001
    elst = []
    ans = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if lst[e]:
            pass
        else:
            elst.append(e)

        lst[e] = lst[e] + p*q

    for i in elst:
        if lst[i] >= 1000000:
            ans.append(i)

    if ans == []:
        print('NA')
    
    else:
        for i in ans:
            print(i)
