#include<iostream>
using namespace std;
int main() {
	int ans[1111],n,an,ban[1111],ba;
	while (1) {
		cin >> n;
		if (n == 0) {
			goto x;
		}
		an = 0;
		ba = 0;
		for (int i = 1; i <= n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			for (int z = 1; z <= an; z++) {
				if (ban[z] == a) {
					ans[z] = ans[z] + b * c;
					goto a;
				}
			}
			an = an + 1;
			ans[an] = b * c;
			ban[an] = a;
		a:;
		}
		int kk;
		kk = 0;
		for (int i = 1; i <= an; i++) {
			if (ans[i] >= 1000000) {
				cout << ban[i] << endl;
				kk = 1;
			}
		}
		if (kk == 1) {
			kk = 0;
		}
		else {
			cout << "NA" << endl;
		}
	}
x:;
}
