#include <stdio.h>
#include <string.h>

int member[4010][3] ;
int price[4010] ;
bool vis[4010] ;

int main ( )
{
	int n ; 
	bool na ;
	int low ;
	int high ;
	while ( scanf ( "%d" , &n ) == 1 && n ){
		low = 2147483600 ;
		high = -1 ;
		na = false ;
		memset ( vis , false , sizeof ( vis ) ) ;
		memset ( price , 0 , sizeof ( price ) ) ;
		for ( int i = 0 ; i < n ; i++ ){
			scanf ( "%d %d %d" , &member[i][0] , &member[i][1] , &member[i][2] ) ;
			int tmp = member[i][1] * member[i][2] ;
			price[member[i][0]] += tmp ;
			vis[member[i][0]] = true ;
			high = ( member[i][0] > high ) ? member[i][0] : high ;
			low = ( member[i][0] < low ) ? member[i][0] : low ;
		}
		for ( int i = low ; i <= high ; i++ ){
			if ( vis[i] == true && price[i] >= 1000000 ){
				printf ( "%d\n" , i ) ;
				na = true ;
			}
		}
		if ( ! na ){
			printf ( "NA\n" ) ;
		}
	}
	return 0 ;
} 