#include <iostream>
#include <cstring>
using namespace std;

int main(){
	long long int n,i,price[4000],a,b,c;
	bool flag;
	while(cin >> n && n){
		flag = false;
		memset(price,'\0',sizeof(price));
		for(i = 0;i < n;++i){
			cin >> a >> b >> c;
			price[a-1] += b * c;
		}
		for(i = 0;i < 4000;++i){
			if(price[i] >= 1000000){
				cout << i + 1 << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}