while True:
    n = int(input())
    if n is 0:
        break
    dic = {}
    for i in xrange(n):
        key,p,q = map(int,raw_input().split())
        if key in dic:
            dic[key] += p*q
        else:
            dic[key] = p*q

    flag = False
    for i in dic.items():
        if i[1] >= 1000000:
            print i[0]
            flag = True

    if not flag:
        print "NA"