#include<iostream>
#include<algorithm>
#include<map>

typedef long long ll;

int main()
{
	int n;
	std::map<int, ll> m;

	while( std::cin >> n, n )
	{
		m.clear();

		for( ll a, b, c, i = 0; i < n; ++i )
		{
			std::cin >> a >> b >> c;
			m[a] += b * c;
		}

		bool f = false;
		for( auto it = m.begin(); it != m.end(); ++it )
			if( it->second >= 1000000 )
				std::cout << it->first << std::endl, f = true;

		if( !f )
			std::cout << "NA" << std::endl;
	}
	return 0;
}