#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<string.h>

int main()
{
	int n;
	__int64 v[4001];
	std::vector<int> vec;
	
	while( 1 ){
		std::cin >> n;
	
		if( !n ) break;
		
		memset( v, 0, sizeof( v ) );
		vec.clear();
		
		while( n-- ){
			int num;
			int a, b;
		 	std::cin >> num >> a >> b;
			
			v[num] += (__int64)( a * b );
			vec.push_back( num );
		}
		
		for( int i = 1; i <= 4000; i++ ){
			if( v[i] < 1000000 ) v[i] = 0;
			else v[i] = 1;
		}
		
		if( std::count( v + 1, v + 4001, 1 ) == 0 ){
		 	std::cout << "NA" << std::endl;
		}
		else{
			std::set<int> s;
		
			for( std::vector<int>::iterator it = vec.begin(); it != vec.end(); it++ ){
				if( v[*it] && s.find( *it ) == s.end() ){
				 	std::cout << *it << std::endl;
				}
				
				s.insert( *it );
			}
		}
	}

 	return 0;
}