#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int in;
cin >> in
int p[in][in * 3],i,ii,c = 0,uri[in],k;	
	for(i = 1;in >= i;i++){ cin >> p[i][0] >> p[i][1] >> p[i][2];uri[i] = 0;}	
	for(i = 1;in >= i;i++){
		for(ii = 1;in >= ii;ii++){if(p[i][0] == p[ii][0]){ uri[ii] = uri[ii] + p[i][1] * p[i][2];}}
	}
	for(i = 1;in >= i;i++){
		k = 0;
		for(ii = 1;i > ii;ii++){if(p[i][0] == p[ii][0]){ k = 1;} }		
			if(uri[i] >= 1000000 and k == 0){cout << p[i][0] << endl; c++;} 
	}
	if(c == 0 and in != 0) cout << "NA" << endl;

}