#include<iostream>
#include<queue>

struct data{
	int num;
	long long pri;
	long long cun;
};

struct ret{
	int num;
	long long sales;
};

int main(){
	while (1){
		int n;
		std::cin >> n;
		if (n == 0)break;
		std::queue<data> que;
		for (int i = 0; i < n; ++i){
			data person;
			std::cin >> person.num >> person.pri >> person.cun;
			que.push(person);
		}
		std::vector<ret> lis;
		while (!que.empty()){
			data perso = que.front();
			if (!lis.empty()){
				bool f = false;
				for (auto it = lis.begin(); it != lis.end(); ++it){
					ret pers = *it;
					if (perso.num == pers.num){
						f = true;
						//std::cout << "t" << std::endl;
						//std::cout << pers.sales << std::endl;
						pers.sales += perso.cun * perso.pri;
						//std::cout << pers.sales << std::endl;
						std::swap(pers, *it);
					}
				}
				if (!f){
					ret newperson;
					newperson.num = perso.num;
					newperson.sales = perso.cun * perso.pri;
					lis.push_back(newperson);
				}
			}
			else{
				ret newperson;
				newperson.num = perso.num;
				newperson.sales = perso.cun * perso.pri;
				lis.push_back(newperson);
			}
			que.pop();
		}
		bool exist = false;
		for (auto it = lis.begin(); it != lis.end(); ++it){
			ret per = *it;
			//std::cout << per.num << " " << per.sales << std::endl;
			if (per.sales >= 1000000)std::cout << per.num << std::endl, exist = true;
		}
		if (!exist)std::cout << "NA" << std::endl;
	}
	//std::system("pause");
	return 0;
}