#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			ll s; int f; s = it->second; f = it->first;
			if(s >= 1000000){
				ok = false;
				printf("%d\n", f);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}