while(True):
    n = int(input())
    if n == 0:
        break
    c = 0
    l = []
    d = {}
    for i in range(n):
        num,x,y = map(int,input().split())
        if num in d:
            d[num] = d[num] + x*y
        else:
            d[num] = x*y
            l.append(num)
    for i in l:
        if d[i] >= 1000000:
            print(i)
            c += 1
    if c == 0:
        print('NA')