#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0){
			break;
		} // end if

		map<int, long long> res;
		int i;

		for (i = 0; i < n; ++i){
			getline (cin, str );
			int id, p, q;
			stringstream ss(str);

			ss >> id >> p >> q;
			long long sum = (long long)(p*q);
			res[id] += sum;
		} // end loop

		map<int, long long>::iterator it = res.begin();
		map<int, long long > R;

		for (; it != res.end(); ++it){
			int id = (*it).first;
			long long sum = (*it).second;

			if (sum >= 1000000LL ){
				R[id] = sum;
			} // end if
		} // end for

		if (R.empty() ){
			cout << "NA" << endl;
		}else{
			map<int, long long>::iterator itr = R.begin();
			for (; itr != R.end(); ++itr ){
				cout << (*itr).first << endl;
			} // end for
		} // end if
	} // end while
		
	return 0;
}