datasets=[]
while True:

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

  inputs=[None]*n
  for t in range(0,n):
    inputs[t] = list(map(int,input().split()))
    #inputs == [[i0,p0,q0],[i1,p1,q1],[i2,p2,q2]]

  id_sale = [] # id_sale == [id,sale,id,sale,id,sale]
  for i in inputs: # i == [ik,pk,qk]
    try:
      id_sale[id_sale.index(i[0])+1] += i[1]*i[2]
    except ValueError:
      # output in the order of inputting
      # (list1 += list2) == [list1_elements, list2_elements]
      id_sale += [i[0],i[1]*i[2]]

  na=True
  for i in range(0,len(id_sale),2):
    if id_sale[i+1] >= 1000000:
      print(id_sale[i])
      na=False
  if na:
    print("NA")