from collections import Counter

while True:
    n = int(input())
    if n == 0:
        break
    counter = Counter()
    for _ in [0]*n:
        a, b, c = map(int, input().split())
        counter[a] += b*c
    result = [str(k) for k, v in counter.items() if v >= 1000000] or ["NA"]
    print("\n".join(result))
    
