#include <cstdio>
#include <map>
#include <vector>

using namespace std;

int main(){
	int n;
	map<int,long> list;
	vector<int> people;
	while(scanf("%d",&n) != EOF && n){
		int a,b,c;
		list.clear();
		people.clear();
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);
			people.push_back(a);
			list[a] += b * c;
		}
		vector<int>::iterator it;
		bool flag = true;
		for(it = people.begin();it != people.end();it++){
			
			if(list[*it] >= 1000000){
				printf("%d\n",*it);
				flag = false;
			}
			
			list[*it] = 0;
		}
		if(flag){
			printf("NA\n");
		}
	}
}