while True:
    num = int(raw_input())
    if num == 0: exit()

    d = {}
    cnt = 0
    for i in range(num):
        uid, p, q = map(int, raw_input().split(" "))
        if d.has_key(uid): d[uid] += p * q
        else: d[uid] = p * q

    sorted(d.items())
    for i in d:
        if d[i] >= 1000000:
            print i
            cnt += 1
    if cnt == 0: print "NA"