loop {
    n = gets.to_i
    break if n == 0
    total = Hash.new(0)
    n.times {
        i, p, k = gets.split.map(&:to_i)
        total[i] += p * k
    }
    a = total.keys.select{|i| total[i] >= 1000000}.sort
    puts a.empty? ? "NA" : a
}