import std.stdio, std.algorithm, std.conv, std.string;

void main(){
    while(true){
        int[int] m;
        int n=readln.chomp.to!int;
        if(!n)break;
        foreach(_;0..n){
            auto inp=readln.split.map!(to!int);
            m[inp[0]]+=inp[1]*inp[2];
        }
        bool printed;
        foreach(num,val;m){
            if(val>=1_000_000){
                num.writeln;
                printed=true;
            }
        }
        if(!printed)"NA".writeln;
    }
}