#include<cstdio>
#include<map>
#include<vector>
int main() {
	std::map<int, int> mp;
	std::vector<int> v;
	int n, i, e, p, q;
	while (true) {
		mp.clear();
		v.clear();
		scanf("%d", &n);
		if (n == 0)break;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d", &e, &p, &q);
			if (mp.count(e) == 0) mp[e] = p*q;
			else mp[e] += p*q;
		}
		for (std::map<int, int>::iterator itr = mp.begin(); itr != mp.end(); ++itr) {
			if (itr->second >= 1000000)v.push_back(itr->first);
		}
		if (v.size() == 0)printf("NA\n");
		else {
			for (std::vector<int>::iterator itr = v.begin(); itr != v.end(); ++itr) {
				printf("%d\n", *itr);
			}
		}
	}
	return 0;
}

