while n=gets.to_i
  break if n == 0
  h = {}
  n.times{
    (n,d,c)=gets.split(/ /).map(&:to_i)
    h[n]=0 if !h.key?(n)
    h[n]+=d*c
  }
  r = h.select{|k,v| v >= 1000000}.keys

  if r.size == 0
    puts "NA"
  else
    puts r
  end
end