while n = gets.to_i do
    if n==0 then
        break
    end
    x=Array.new(4000,0)
    bool =false
    for i in 1..n do
        line = gets
        a,b,c = line.split.map(&:to_i)
        x[a]+=b*c
        if x[a]>=1000000 then
            puts a
            x[a]=-1000000
            bool=true
        end
    end
    if bool==false then
        puts 'NA'
    end
end