#include <iostream>
#include <vector>

using namespace std;

const int Target = 1000000;

struct Shain {
	int no;
	long long sum;
};

int main( void )
{
	vector<Shain> shain;
	int n;
	while(cin >> n, n) {
		shain.clear();
		for(int i=0; i < n; ++i) {
			int no, kin, num;
			cin >> no >> kin >> num;
			bool hit = false;
			vector<Shain>::iterator it = shain.begin();
			while(it != shain.end()) {
				if(it->no == no) {
					it->sum += (kin * num);
					hit = true;
					break;
				}
				++it;
			}
			if(!hit) {
				Shain tmp;
				tmp.no = no;
				tmp.sum = kin * num;
				shain.push_back(tmp);
			}
		}
		bool hit = false;
		vector<Shain>::iterator it = shain.begin();
		while(it != shain.end()) {
			if(it->sum >= Target) {
				cout << it->no << endl;
				hit = true;
			}
			++it;
		}
		if(!hit)
			cout << "NA" << endl;
	}
	return 0;
}