#include <bits/stdc++.h>
int main(void) {
  int flag, memo[4001];
  long long int table[4001], a, b, n, no, i;
  while (1) {
    scanf("%lld", &n);
    if (n == 0) break;
    for (i = 1; i <= 4000; i++) table[i] = memo[i] = 0;
    for (i = 1; i <= n; i++) {
      scanf("%lld %lld %lld", &no, &a, &b);
      if (memo[no]) continue;
      table[no] += a * b;
      if (table[no] >= 1e6) memo[no] = 1;
    }
    flag = 0;
    for (i = 1; i <= 4000; i++) {
      if (table[i] >= 1e6) {
        printf("%lld\n", i);
        flag = 1;
      }
    }
    if (flag == 0) printf("NA\n");
  }
  return 0;
}
