until (n = gets.to_i).zero?
  h = Hash.new(0)
  
  n.times do
    arr = gets.split.map(&:to_i)
    h[arr[0]] += arr[1] * arr[2]
  end
  
  h = h.select{ |k, v| v >= 1_000_000 }
  
  puts h.empty? ? "NA" : h.keys
end