#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

#define MAX_I (1001)

class Data{
public:
	int e;
	long pq;
	int i;

	Data() : e(0), pq(0), i(MAX_I){
		return;
	}

	~Data(){
		return;
	}

	bool operator < (const Data &r){
		return this->i < r.i;
	}
};

int main(int argc, char **argv){
	int n, e, p, q;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	while(ifs >> n){
#else
	while(std::cin >> n){
#endif
		if(n == 0){ break; }

		std::vector<Data> data(4001);
		std::vector<int> result;

		for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
			ifs >> e >> p >> q;
#else
			std::cin >> e >> p >> q;
#endif
			if(data[e].i == MAX_I){
				data[e].i = i;
			}
			data[e].e = e;
			data[e].pq += p * q;
		}

		std::sort(data.begin(), data.end());

		for(int i = 0; i < data.size(); i++){
			if(data[i].pq >= 1000000){
				result.push_back(data[i].e);
			}
		}
		if(result.empty()){
			std::cout << "NA" << std::endl;
		}
		else{
			for(int i = 0; i < result.size(); i++){
				std::cout << result[i] << std::endl;
			}
		}
	}
	

#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}
