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

using namespace std ;

int member[4010][3] ;
int price[4010] ;
int idx[4010] ;

struct ANS{
	bool ans ;
	int num ;
}A[4010];

bool cmp ( int a , int b ) ;

int main ( )
{
	int n ; 
	bool na ;
	while ( scanf ( "%d" , &n ) == 1 && n ){
		na = false ;
		memset ( price , 0 , sizeof ( price ) ) ;
		for ( int i = 0 ; i < 4010 ; i++ ){
			A[i] . ans = false ;
			A[i] . num = 9999 ;
			idx[i] = i ;
		}
		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 ;
			if ( price[member[i][0]] >= 1000000 ){
				A[member[i][0]] . ans = true ;
				na = true ;
			}
			A[member[i][0]] . num = ( A[member[i][0]].num == 9999 ) ? i : A[member[i][0]] . num ;
		}
		if ( ! na ){
			printf ( "NA\n" ) ;
		}
		else{
			sort ( idx , idx + 4010 , cmp ) ;
			for ( int i = 0 ; i < 4010 ; i++ ){
				if ( A[idx[i]] . ans == true ){
					printf ( "%d\n" , idx[i] ) ;
				}
			}
		}
	}
	return 0 ;
} 

bool cmp ( int a , int b )
{
	return A[a] . num < A[b] . num ;
}