#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)break;
		long long u[4010] = { 0 };
		for (int i = 0; i < n; i++){
			long a, b, c;
			cin >> a >> b >> c;
			u[a] += b*c;
		}
		bool b = true;
		for (int i = 1; i < 4001; i++){
			if (u[i] >= 1000000) {
				cout << i << endl;
				b = false;
			}
		}
		if (b)cout << "NA" << endl;
	}
	return 0;
}