#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <cmath>
#include <map>


int main(int,char**){
	typedef std::map<short,long long> Data;
	
	int n;
	while(std::cin>>n){
		if(!n) break;
		bool ex(0);
		Data tbl;
		while(n--){
			int Cnum,at,num;
			std::cin >>Cnum>>at>>num;
			tbl[Cnum]+=at*num;
		}
		for(Data::const_iterator it=tbl.begin();it!=tbl.end();++it){
			if((it->second)>=1000000){ std::cout<< it->first << std::endl; ex=1;}
		}
		if(!ex) std::cout << "NA"<<std::endl;
	}

	return 0;
}