
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) {
    int[][int] table;
    foreach(i; 0..times) {
      int[] data = readln.chomp.split(" ").map!(to!(int)).array;
      if (data[0] in table) {
        table[data[0]][0] += data[1] * data[2];
      }
      else {
        table[data[0]] = new int[](3);
        table[data[0]][0] = data[1] * data[2];
        table[data[0]][1] = i;
        table[data[0]][2] = data[0];
      }
    }
    int[] result =
      sort!((int[] x, int[] y) => x[1] < y[1])(table.values).filter!((x) => x[0] >= 1e6).map!(x => x[2]).array;
    writeln(result == [] ? "NA" : result.map!(to!(string)).join(" "));
  }
}