while True:
    n = int(input())
    if n == 0: break
    personel = {}
    for _ in range(n):
        e, p, q = input().split()
        if e in personel.keys():
            personel[e] += int(p) * int(q)
        else:
            personel[e] = int(p) * int(q)
    result = []
    for key, val in personel.items():
        if val >= 1000000:
            result.append(key)
    if not result:
        print('NA')
    else:
        print('\n'.join(result))

