while 1:
  n=input()
  if n==0: break
  D={}
  A=[]
  for _ in range(n):
    a,b,c=map(int, raw_input().split(' '))
    if a in D: D[a]+=b*c
    else:
      D[a]=b*c
      A.append(a)
  B=[i for i in A: if D[i]>=1e6]
  if B=[]: B=["NA"]
  for e in B: print e