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

int main()
{
	int n;
	std::pair<int, int> v[4001];
	bool used[4001];
	
	while( 1 ){
		std::cin >> n;
	
		if( !n ) break;
	
		memset( v, 0, sizeof( v ) );
		memset( used, false, sizeof( used ) );
		
		while( n-- ){
			int num;
			int a, b;
		 	std::cin >> num >> a >> b;
			
			if( !used[num] ){
				v[num] = std::pair<int,int>( a, b );
				used[num] = true;
			}
			else{
				v[num].first += a;
				v[num].second += b;		
			}
		}
		
		for( int i = 0; i < 4001; i++ ){
			if( v[i].first == 0 && v[i].second == 0 ) continue;
			
			long long p = v[i].first * v[i].second;
			
			if( p < 1000000 ){
			 	v[i].first = v[i].second = 0;
			}
		}
		
		if( std::count( v, v + 4001, std::pair<int,int>( 0, 0 ) ) == 4001 ){
		 	std::cout << "NA" << std::endl;
		}
		else{
		 	for( int i = 1; i < 4001; i++ ){
				if( v[i].first && v[i].second )std::cout << i << std::endl;
			}
		}
	}

 	return 0;
}