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

    d = {}
    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

    if max(d.values()) < 1000000: print "NA"
    else:
        reversed(d.items())
        for i in d:
            if d[i] >= 1000000: print i