while True:
  count = int(input())
  if count == 0: break
  ans,v,t = 0,0,[]
  for i in range(count):
    a,b,c = map(str,raw_input().split())
    v = int(b)*int(c)
    v= str(v)
    if len(v) >= 7:
      if a in t:
        continue
      else:
        print a
        t.append(a)
        ans +=1
        continue
  if ans == 0:
    print "NA"
    continue
  else: continue