#include <iostream>
#include <string>
using namespace std;

int main(){
	int n, num, count;
	long long int p, q, nu[5000];
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < 5000; i++) {
			nu[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> num >> p >> q;
			nu[num] += p * q;
		}
		count = 0;
		for (int i = 1; i < n; i++) {
			if(nu[i]>999999){
				cout << i << endl;
				count++;
			}
		}
		if (count==0){
			cout << "NA" << endl;
		}
	}
	return 0;
}