#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
int main(){
  while(1){
    ll i,b[4010],a[4010],n,e[4010],p,q,k=0;
    scanf("%lld\n",&n);
    if(n==0){
      return 0;
    }
    for(i=0;i<=4000;i++){
      a[i]=0,b[i]=0;
    }
    for(i=0;i<n;i++){
      scanf("%lld %lld %lld\n",&e[i],&p,&q);
      a[e[i]]+=p*q;
    }
    for(i=0;i<n;i++){
      if(b[e[i]]==0 && a[e[i]]>=1000000){
        b[e[i]]=1;
        printf("%lld\n",e[i]);
        k++;
      }
    }
    if(k==0){
      printf("NA\n");
    }
  }
  return 0;
}
