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

    data = {}
    ans = []
    for i in range(n):
        tmp = list(map(int, input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]

    for k, v in data.items():
        if v >= 1000000:
            ans.append(str(k))

    if len(ans) == 0:
        print('NA')
    else:
        print('\n'.join(ans))