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