#include <bits/stdc++.h>
int main(void) {
  int i, f = 0;
  int num, mem;
  long long int sum[4000] = {0};
  long long int m, count;
  while (1) {
    f = 0;
    scanf("%d", &mem);
    if (mem == 0) break;
    for (i = 0; i < mem; i++) {
      scanf("%d %lld %lld", &num, &m, &count);
      if (sum[num] != -1) sum[num] += m * count;
      if (sum[num] >= 1000000) {
        printf("%d\n", num);
        sum[num] = -1;
        f = 1;
      }
    }
    if (f == 0) printf("NA\n");
  }
  return 0;
}
