#include<bits/stdc++.h>
#define int long long
using namespace std;
 
signed main(){
int a;
while(scanf("%lld",&a),a){
    unordered_map<int,int>c;
    for(int d=0;d<a;d++){int e,f,k;scanf("%lld%lld%lld",&e,&f,&k);c[e]+=f*k;}
    bool s=true;
    for(auto g=c.begin();g!=c.end();g++){
	if(g->second>=1000000){s=false;printf("%lld\n",g->first);}
	}
	if(s)printf("NA\n");
    }
}