while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    for _ in range(n):
        i, p, q = map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
    tmp = sorted(d.items(), key=lambda x: x[0])
    tmp = list(filter(lambda x: x[1] >= 1000000, tmp))
    if len(tmp):
        for t in tmp:
            print(t[0])
    else:
        print("NA")