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

typedef long long ll;

int n;
ll p[4000];
std::vector<int> ord;

int main()
{
	while( std::cin >> n, n )
	{
		memset( p, 0, sizeof( p ) );
		ord.clear();

		for( ll a, b, c, i = 0; i < n; ++i )
		{
			std::cin >> a >> b >> c;
			if( p[a-1] == 0 )ord.push_back( a - 1 );	
			p[a-1] += b * c;
		}
		bool fl = false;
		for( int i = 0; i != ord.size(); ++i )
			if( p[ord[i]] >= 1000000 )
				std::cout << ord[i] + 1 << std::endl, fl = true;

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