process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input){
    var line = input.trim().split("\n");
    var i = 0;
    while(line[i] !== '0')
    {
        var N = parseInt(line[i++].trim());
        {
            var found, len, k, res;
            var qualified = [], amount = [];
            for(--N;N>=0;--N){
                var dataset = line[i++].trim().split(" ");
                res = parseInt(dataset[1]) * parseInt(dataset[2]);
                
                found = 0;
                for(k=0;k<qualified.length;++k){
                    if(qualified[k] == dataset[0]){
                        found = 1;
                        amount[k] = amount[k] + res;
                        break;
                    }
                }
                
                if( !found ){
                    qualified.push(dataset[0]);
                    amount.push(res);
                }
            }
            
            found = 0;
            len = qualified.length;
            for(k=0;k<len;++k){
                if( amount[k] >= 1000000 ){
                    console.log(qualified[k]);
                    found = 1;
                }
            }
            if( !found ){
                console.log("NA");
            }
        }
    }
});