//AOJ 0100
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define MAX_N 100
 
unsigned long long int a[4001] = {0}, b, i, j, k, ans, n;
char str[1000];
 
int sort(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}
 
int main(){
  while(scanf("%lld", &n) != 0){
    if(n == 0) return 0;
    ans = 0;
    for(i = 0; i < 4001; i++)
      a[i] = 0;
    for(i = 0; i < n; i++){
      scanf("%lld %lld %lld", &b, &k, &j);
      if(a[b] >= 1000000) continue;
      a[b] += k * j;
      if(a[b] >= 1000000){
    printf("%lld\n", b);
    ans++;
      }
    }
    if(ans == 0) printf("NA\n");
  }
  return 0;
}