while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    d=int(b)*int(c)
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:print(a);f=0
  if f:print('NA')