/*
	AOJ_0100: Sale Result
*/
#include	<iostream>
#include	<vector>
#include	<utility>

using namespace std;

typedef unsigned long long ull;

class employee {
private:
	int number;
	ull proceed;
public:
	employee() {
		number = 1;
		proceed = 0;
	}
	employee(int _n, ull _p) {
		number = _n;
		proceed = _p;
	}
	void addProceed(ull in_prcd) {
		if (proceed < 1000000) { proceed += in_prcd; }
	}
	bool isSatisfy(void) {
		return (proceed >= 1000000 ? true : false);
	}
	int showNumber(void) {
		return number;
	}
};

int main(void) {
	vector<employee> Emps;
	int n, member, price, count;
	ull buf_prcd;
	bool isNothing, isNotHit;

	while (1) {
		isNothing = true;

		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> member >> price >> count;
			buf_prcd = price * count;
			isNotHit = true;

			vector<employee>::iterator it = Emps.begin();
			while (it != Emps.end()) {
				if (it->showNumber() == member) {
					isNotHit = false;
					it->addProceed(buf_prcd);
					break;
				}
				it++;
			}
			if (isNotHit) {
				Emps.push_back( employee(member, buf_prcd) );
			}
		}

		isNotHit = true;
		vector<employee>::iterator it = Emps.begin();
		while (it != Emps.end()) {
			if (it->isSatisfy() == true) {
				isNotHit = false;
				cout << it->showNumber() << endl;
			}
			it++;
		}
		if (isNotHit) {
			cout << "NA" << endl;
		}
		Emps.clear();
	}
	return 0;
}