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

    dic = {}
    odr = []
    for i in range(num):
        uid, p, q = map(int, raw_input().split())
        if dic.has_key(uid): dic[uid] += p * q
        else:
            dic[uid] = p * q
            odr.append(uid)

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