process.stdin.resume();
process.stdin.setEncoding('utf8');
 
process.stdin.on('data', function(input){
    var line = input.trim().split('\n');
    var i = 0;
    while(true){
        var N = parseInt(line[i]);
        if( N === 0 ){
            break;
        }
        else{
            var found, len, k, res;
            var qualified = [];
            for(var j=0;j<N;++j){
                var dataset = line[++i].split(' ');
                res = parseInt(dataset[1]) * parseInt(dataset[2]);

                if( res >= 1000000 ){
                    found = 0;
                    len=qualified.length;
                    for(k=0;k<len;++k){
                        if(qualified[k] == dataset[0]){
                            found = 1;
                            break;
                        }
                    }
                    
                    if( found === 0 ){
                        qualified.push(dataset[0]);
                    }
                }
            }
            
            len = qualified.length;
            if( len === 0 ){
                console.log("NA");
            }
            else{
                for(k=0;k<len;++k){
                    console.log(qualified);
                }
            }
        }
    }
});