while True:
    n = int(input())
    if n == 0:
        break

    rs = {}
    for i in range(n):
        arr = [int(x) for x in input().split(' ')]
        s = arr[1] * arr[2]
        rs[arr[0]] = (rs.get(arr[0]) or 0) + s

    top = [k for k, v in rs.items() if v > 1000000 ]
    if len(top) == 0:
        print('NA')
    else:
        for i in top:
            print(i)