while True:
    N = int(raw_input())
    if N == 0: break
    dic = {}
    for i in range(N):
        n, p, q = map(int, raw_input().split())
        if not n in dic:
            dic[n] = [i,p*q]
        else:
            dic[n][1] = dic[n][1]+p*q
            
    lis = [(v[0], k) for k, v in dic.items() if v[1] >= 1000000]
    if lis:
        for t in sorted(lis, key=lambda x: x[0]):
            print t[1]
    else:
        print 'NA'