while True:
    n = int(input())
    if n == 0: break
    d = dict()
    order = []
    for _ in range(n):
        i, p, q = map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
        if i not in order: order.append(i)
    b = True
    for o in order:
        if d[o] > 999999:
            print(o)
            b = False
    if b: print("NA")