(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n"), index = 0, exist, salesData, n, i, datas, num, sales;
    while(inputs[index] !== '0') {
        salesData = [];
        exist = false;
        n = parseInt(inputs[index++]);
        for(i = index; i < n + index; i++) {
            datas = inputs[i].split(' ');
            num = parseInt(datas[0]);
            sales = parseInt(datas[1]) * parseInt(datas[2]);
            if(salesData[num] === undefined) {
                salesData[num] = 0;
            }
            salesData[num] += sales;
        }
        salesData.forEach(function (sales, i) {
            if(sales >= 1000000) {
                console.log(i);
                exist = true;
            }
        });
        if(!exist) {
            console.log('NA');
        }
        index += n;
    }
})(require("fs").readFileSync("/dev/stdin", "utf8"));