#include <iostream>

using namespace std;

int main(){
	int n;
	int x[4001] = {0};
	int m[4001] = {0};
	
	while(1){
		int e, p, q;
		cin >> n;
		if(n == 0) break;
		x[4001] = {0};
		
		bool flag = true;
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			m[i] = e;
			x[e] += p * q;
			}
		
		for(int i = 1; i <= n; i++){
			if(x[m[i]] >= 1000000){
				cout << m[i] << end;
				x[m[i]] = 0;
				flag = false;
			}
		}
		if(flag) cout << "NA" << endl;
	}
	
	return 0;
}