while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
  for i in d:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')