
#include <stdio.h>
#include <iostream>
#include <map>
#include <set>
using namespace std;

typedef long long int ll;

ll solve(ll N);

int main(void) {

	ll N = 1;
	while(true) {
		cin >> N;
		if( N == 0 ) { break; }
		solve(N);
	}

	return 0;
}

ll solve( ll N ) {

	map<int, ll> m;
	set<int> s;

	for( int i = 0; i < N; i++ ) {
		int id;
		ll ps, q;
		cin >> id >> ps >> q;
		if( m.find(id) == m.end() ) {
			m[id] = ps*q;
		} else {
			m[id] += ps*q;
		}
		if( m[id] >= 1000000 ) 
			s.insert(id);
			
	}

	if( s.size() == 0 ) {
		cout << "NA" << endl;
	} else {
		for( auto it = s.begin(); it != s.end(); ++it ) {
			cout << (*it) << endl;
		}
	}
	return 0;
}