n = int(input())
while (n != 0):
    e_ab = {}
    for i in range(n):
        e,a,b = map(int, input().split())
        ab = a*b
        if (e not in e_ab.keys()):
            e_ab[e] = ab
        else:
            e_ab[e] += ab
    c = 0
    for e,ab in e_ab.items():
        if (ab >= 10**6):
            c += 1
            print(e)
    if (c == 0):
        print('NA')
    
    n = int(input())
