from collections import OrderedDict

while True:
    n = int(input())
    if n == 0:
        break
    ans = OrderedDict()
    for i in range(n):
        e, p, q = [int(x) for x in input().split()]
        if e in ans:
            ans[e] += p * q
        else:
            ans[e] = p * q
    flag = True
    for k, v in ans.items():
        if v >= 1000000:
            flag = False
            print(k)
    if flag:
        print('NA')