import sys
def func(num):
   dict = {}
   for i in range(len(num)):
       if num[i][0] not in dict.keys():
           dict[num[i][0]] = int(num[i][1]) * int(num[i][2])
       else:
           dict[num[i][0]] = dict[num[i][0]] + int(num[i][1]) * int(num[i][2])
   list = dict.keys()
   flag = 0
   for i in list:
       if dict[i] >= 1000000:
           print(i)
           flag = 1
   if flag == 0:
       print("NA")
flag = 0
count = 0
n = 0
num = []
for line in sys.stdin.readlines():
   if flag == 0:
       n = int(line)
       if n == 0:
           break
       flag = 1
       count = 0
   elif flag == 1:
       count += 1
       num.append(line.split())
       if count == n:
           flag = 0
           func(num)
           del(num)
           num = []