#include <iostream>
#include <algorithm>
#include <vector>

int main(){
	int n;
	while(std::cin>>n){
		std::vector<int> v;
		if(!n)return 0;
		for(;n;n--){
			long long int num,price,quantity;
			std::cin>>num>>price>>quantity;
			if(price*quantity>=1000000){
				std::vector<int>::iterator it = std::find(v.begin(),v.end(),num);
				if(it==v.end())
					v.push_back(num);
			}
		}
		if(!v.size())std::cout<<"NA"<<std::endl;
		else{
		std::vector<int>::iterator it = v.begin();
		while(it!=v.end()){
			std::cout<<*it<<std::endl;
			it++;
		}
		}
	}
}