var d = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n');
while (d[0] !== '0') {
  var lc = d.shift();
  var data = [];
  for (var i = 0; i < lc; i++) {
    var info = d.shift().split(' ');
    var j = -1;
    for (var k = 0; k < data.length; k++) {
      if (data[k].no === info[0]) { j = k; break; }
    }
    var person = (j === -1) ? data[data.length] = {no: info[0], sales: 0} : data[j];
    person.sales += info[1] * info[2];
  }
  console.log(data.filter(function(d) { return d.sales >= 1000000; })
    .map(function(d) { return d.no; }).join('\n') || 'NA');
}