#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n = 0;				//  社員の人数;n==0で終了
	bool flag = true;		//  flagはidの重複を確認する
	int id_temp,price_temp,amount_temp;
	vector<int> id;			//  社員のid
	vector<int> price;		//  the corresponding unit price
	vector<int> amount;		//  the amount of sales
	vector<int> result;		//  条件を満たすid郡

	while(true) {
		cin >> n;
		if(n<0) {
			cout << "Error; n must be larger than 0";
			return -1;
		}
		else if(n==0)
			break;
		else {
			result.clear();
			id.clear();
			price.clear();
			amount.clear();
			for(int i=0;i<n;i++) {
				cin >> id_temp >> price_temp >> amount_temp;
				flag = true;
				for(int j=0;j<id.size();j++)
					if(id_temp==id[j]) {
						price[j] += price_temp;
						amount[j] += amount_temp;
						flag = false;
						break;
					}
				if(flag) {
					id.push_back(id_temp);
					price.push_back(price_temp);
					amount.push_back(amount_temp);
				}
			}

			for(int i=0;i<n;i++) 
				if(price[i]*amount[i]>=1000000)
					result.push_back(id[i]);
			
			if(result.size()==0)
				cout << "NA" << endl;
			else
				for(int i=0;i<result.size();i++)
					cout << result[i] << '\n';
		}
	}

	return 0;
}