#include <bits/stdc++.h>
long long int n, id, p, q, num, time, min, max, sale[1000000][2];
long long int i, j, k;
int main(void) {
  while (scanf("%lld", &n) * n) {
    num = 0;
    min = 1000000;
    max = 0;
    for (i = 0; i < n; i++) {
      scanf("%lld %lld %lld", &id, &p, &q);
      if (id < min) min = id;
      if (id > max) max = id;
      if (sale[id][1] != time) {
        sale[id][0] = p * q;
        sale[id][1] = time;
      } else if (sale[id][0] < 1000000) {
        sale[id][0] += p * q;
        if (sale[id][0] >= 1000000) num++;
      }
    }
    if (num == 0)
      printf("NA\n");
    else {
      for (i = min; i <= max; i++) {
        if (sale[i][0] >= 1000000 && sale[i][1] == time) printf("%lld\n", i);
      }
    }
    time++;
  }
  return 0;
}
