def f(n):
  D = {}
  for _ in [0]*n:
    a,b,c = map(int,raw_input().split(' '))
    try: D[a] += b*c
    except: D[a] = b*c
  B = [i for i,e in D.items() if e>=1e6]
  if not B: B=["NA"]
  return B
 
while 1:
  n = int(raw_input())
  if n==0: break
  for e in f(n): print e