p = []
q = []
while True:
    n = int(input())
    m = 0
    number = [0] * 4000
    if n == 0:
        break
    else:
        for i in range(n):
            p.append(i)
            q.append(i)
            e,p[i],q[i] = [int(s) for s in input().split(' ')]
            if number[e] >= 1000000:
                break
            else:
                number[e] = number[e] + p[i] * q[i]
                if number[e] >= 1000000:
                    print(e)
                else:
                    m = m + 1
            if m == n:
                print('NA')

