class sresult():
 def judge(self,n):
  list={}
  list2=[]
  for i in range(0,n):
   str=raw_input()
   array=str.split(" ")
   no=int(array[0])
   x=no
   sale=int(array[1])
   sold=int(array[2])
   
   if x in list:
    list[no]+=sale*sold
    if list[no]>=1000000 and x not in list2:
     list2.append(no)
   else :
    list.update({x:sale*sold})
    
  for i in range(0,len(list2)):
   print list2[i]
  if len(list2)==0:
    print "NA"
  #print list
if __name__=="__main__":
 ans=sresult()
 while True:
  
  n=input()
  if n==0:
   break
  ans.judge(n)