#include <iostream>
#include <map>

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n == 0){
			break;
		}
		map<int, int> m;
		for(int i = 0; i < n; i++){
			int id, price, amount;
			cin >> id >> price >> amount;
			m[id] += price * amount;
		}
		bool applicable = false;
		for(map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++){
			if(itr->second >= 1000000){
				applicable = true;
				cout << itr->first << endl;
			}
		}
		if(!applicable){
			cout << "NA" << endl;
		}
	}
	return 0;
}