e=[]
while 1:
  l=[list(map(int,input().split())) for i in range(int(input()))]
  if not l:break
  d={}
  for i in l:
    if i[0] not in d:
      d[i[0]]=i[1]*i[2]
    else:
      d[i[0]]+=i[1]*i[2]
  e.append(d)
f=0
for i in e:
  f=0
  for j in i.items():
    if j[1]>=1000000:
      print(j[0])
      f=1
  if not f:
    print("NA")
