while (n = gets.to_i) != 0
  sales = {}
  n.times do
    datas = gets.split.map(&:to_i)
    if sales.include?(datas[0])
      sales[datas[0]][:tanka] += datas[1]
      sales[datas[0]][:soryo] += datas[2]
    else
      sale = {
        tanka: datas[1],
        soryo: datas[2]
      }
      sales[datas[0]] = sale
    end
  end

  flag = false

  sales.each do |k, v|
    if v[:tanka] * v[:soryo] >= 1000000
      flag = true
      puts k
    end
  end

  puts "NA" unless flag
end