from collections import OrderedDict
while True:
    n = int(input())
    if n == 0:
        break    
    dic = OrderedDict()
    for i in range(n):
        line = input().split()
        key = line[0]
        sales = int(line[1]) * int(line[2])
        if key in dic:
            dic[key] += sales
        else:
            dic[key] = sales
    res = [k for k in dic if dic[k] >= 1000000]
    if len(res) == 0:
        print("NA")
    else:
        [print(k) for k in res]