/*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return 0;
	}
#endif
	/*****変数置き場*****/
	int n;
	int num[4000];
	bool appear[4001];
	int howmany;
	int number;
	long long int in_price;
	long long int in_sales;
	long long int price[4001];
	long long int sales[4001];
	/*****処理部*****/
	while(1){
		for(int i=0;i<4001;i++){
			if(i < 4001)	num[i] = 0;
			appear[i] = false;
			price[i] = 0;
			sales[i] = 0;
		}
		howmany = 0;
		cin >> n;
		if(n==0)	break;
		for(int i=0;i<n;i++){
			cin >> number;
			cin >> in_price;
			cin >> in_sales;
			price[number] += in_price;
			sales[number] += in_sales;
			if(!appear[number])	num[i] = number;
			appear[number] = true;
		}
		for(int i=0;i<n;i++){
			if(num[i] != 0){
				if(price[num[i]] * sales[num[i]] >= 1000000){
					cout << num[i] << endl;
					howmany++;
				}
				//cout << num[i] << " " << price[num[i]] << " " << sales[num[i]] << endl;
			}
		}
		if(howmany == 0)	cout << "NA" << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}