#include <iostream>
#include <map>
#include <list>
#include <cmath>
using namespace std;

struct staff {
	unsigned long long int num;
	unsigned long long int price;
	unsigned long long int quan;
	unsigned long long int total;
};

int main()
{
	int num, i, k, j, datas;
	unsigned long long int sn, sp, sq;
	map<int, staff> staffs[4000];
	map<int, staff>::iterator staffs_it;

	datas = 0;
	while(1)
	{
		cin >> num; if(num == 0) break;

		for(i = 0; i < num; i++)
		{
			cin >> sn >> sp >> sq;
			staffs[datas][sn].num = sn;
			staffs[datas][sn].price = sp;
			staffs[datas][sn].quan = sq;
			staffs[datas][sn].total += staffs[datas][sn].price * staffs[datas][sn].quan;
		}
		datas++;
	}

	for(i = 0; i < datas; i++)
	{
		staffs_it = staffs[i].begin();
		int over = 0;

		while(staffs_it != staffs[i].end())
		{
			if(staffs[i][(*staffs_it).first].total >= 1000000)
			{
				cout << staffs[i][(*staffs_it).first].num << endl;
				over++;
			}
			staffs_it++;
		}
		if(over == 0) cout << "NA" << endl;
	}
}	