#include <iostream>
#include <vector>

typedef std::pair<std::string,int> sale;

int main()
{
	
	
	while (true) {
		int n;
		std::vector<sale> sale_vec;
		
		std::cin >> n;
		
		if (n==0) break;
		
		std::string id;
		int unit_price;
		int quantity;
		
		for (int i=0; i<n; i++) {
			std::cin >> id >> unit_price >> quantity;
			bool id_exists = false;
			for (std::vector<sale>::iterator it = sale_vec.begin(); it != sale_vec.end(); ++it) {
				if (it->first == id) {
					id_exists = true; it->second += unit_price * quantity; break;
				}
			}
			if (!id_exists) {
				sale_vec.push_back( sale(id, unit_price * quantity) );
			}
		}
		
		bool output = false;
		for (std::vector<sale>::iterator it = sale_vec.begin(); it != sale_vec.end(); ++it) {
			if (it->second >= 1000000) {
				std::cout << it->first << std::endl;
				output = true;
			}
		}
		if (!output) std::cout << "NA" << std::endl;
	}
	
	return 0;
}
	

