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

void main() {
  int times;
  while((times = readln.chomp.to!(int)) != 0) {
    bool na = true;
    int[int] table;
    bool[int] show;
    foreach(t; 0..times) {
      int[] data = readln.chomp.split(" ").map!(to!(int)).array;
      table[data[0]] += data[1] * data[2];
      if (table[data[0]] >= 1e6 && !(data[0] in show)) {
        writeln(data[0]);
        show[data[0]] = true;
        na = false;
      }
    }
    if (na) writeln("NA");
  }
}