def solve():
    N = int(input())
    if N == 0:
        return False
    E = []
    D = {}
    for i in range(N):
        e, p, q = map(int, input().split())
        E.append(e)
        D[e] = D.get(e, 0) + p*q
    cnt = 0
    for e in E:
        if D.get(e, 0) >= 1000000:
            print(e)
            del D[e]
            cnt += 1
    if cnt == 0:
        print("NA")
    return True
while solve():
    ...

