#include<cstdio>
#include<cstring>

int main(){
long long int data[4000],n;
scanf("%d",&n);
if(n==0) return 0;
memset(data,0,sizeof(data));
while(n--){
int a
long long int b,c;
scanf("%d%lld%lld",&a,&b,&c);
data[a-1]+=b*c;
}
int k=0;
for(int i=0;i<4000;i++){
if(data[i]>=1000000){
 printf("%d\n",i+1);
 k=1;
  } 
}
if(k==0) printf("NA\n");
}