
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
using namespace std;
#define p 1000000 

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);


	while(1){
		long long int n,tmp[3],cnt = 0, flg = 0;
		vector<long long int> number;
		vector<long long int> sales;
		cin >> n;
		if(n == 0) break;
		for(int i=0; i<n; i++) {
			flg = 0;
			cin >> tmp[0] >> tmp[1] >> tmp[2];
			for(int j=0; j<number.size(); j++){
				if(number.at(j) == tmp[0]) {
					sales.at(j) += tmp[1]*tmp[2];
					flg = 1;
					break;
				}
			}
			if(flg == 1) break;
			number.push_back(tmp[0]);
			sales.push_back(tmp[1]*tmp[2]);
		}
		for(int i=0; i<number.size(); i++) {
			if(sales.at(i) >= p) {
				cout << number.at(i) << endl;
				cnt++;
			}
		}
		if(cnt == 0) {
			cout << "NA" << endl;
		} 
	}


	return 0;
}