def sales_price(a, b)
    return a * b
end

def sales_check(staff_num, unit_price, quantity)
    if @sales_hash.key?(staff_num)
        @sales_hash[staff_num] = @sales_hash[staff_num] + sales_price(unit_price, quantity)
    else
        @sales_hash[staff_num] = sales_price(unit_price, quantity)
    end
end

while data_num = gets.to_i
    break if data_num == 0

    @sales_hash = {}
    data_num.times do
        a, b, c = gets.chomp.split(' ').map!(&:to_i)
        sales_check(a, b, c)
    end

    sales_check_result = []
    @sales_hash.each do |staff_num, sales_price|
        if sales_price >= 1000000
            sales_check_result << staff_num
        end
    end

    if sales_check_result == []
        puts "NA"
    else
        puts sales_check_result
    end
end