/* -- 0100:Sale Result -- */
#include	<iostream>
#include	<map>

using namespace std;

typedef unsigned long long ull;

int main(void) {
	int n, buf_n, buf_c, buf_p;
	bool flag;
	ull buf_t;
	map<int, ull> List;

	while(1) {
		cin >> n;
		if(n == 0) { break; }

		flag = true;
		List.clear();
		for(int i=0; i<n; i++) {
			cin >> buf_n >> buf_p >> buf_c;
			buf_t = buf_p * buf_c;
			if(List.find(buf_n) == List.end()) {
				List[buf_n] = buf_t;
			} else {
				List[buf_n] += buf_t;
			}
		}
		map<int, ull>::iterator it = List.begin();
		while( it != List.end() ) {
			if(it->second >= 1000000) { flag = false; cout << it->first << endl; }
			it++;
		}
		if(flag) { cout << "NA" << endl; }
	}
	return 0;
}