while True:
    n = int(input())
    if n == 0: break
  
    data = {}
    staff = []
    for i in range(n):
        x, y, z = [int(el) for el in input().split(' ')]
        if x in data:
            data[x] += y * z
        else:
            data[x] = y * z
            staff.append(x)
  
    if max(data.values()) < 1e6:
        print('NA')
    else:
        for k in staff:
            if data[k] >= 1e6:
                print(k)