while True:
  n = int(input())
  if not n:
    break
  
  dic = {}

  for i in range(n):
    e, p, q = map(int, input().split())    
    if e in dic:
      dic[e] = (dic[e][0], dic[e][1] + p * q)
    else:
      dic[e] = (i, p * q)

  lst = []

  for k in dic:
    if dic[k][1] >= 1000000:
      lst.append((dic[k][0], k))
  
  lst.sort()

  if lst:
    for e in lst:
      print(e[1])
  else:
    print("NA")
