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

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

int main()
{
	int num, i, k, j;
	int sn, sp, sq;
	map<int, staff> staffs;

	while(1)
	{
		cin >> num; if(!num) break;
		staffs.clear();

		for(i = 0; i < num; i++)
		{
			cin >> sn >> sp >> sq;
			staffs[sn].num = sn;
			staffs[sn].price = sp;
			staffs[sn].quan = sq;
			staffs[sn].total += staffs[sn].price * staffs[sn].quan;
		}
		map<int, staff>::iterator staffs_it = staffs.begin();
		int over1000000 = 0;
		while(staffs_it != staffs.end())
		{
			if(staffs[(*staffs_it).first].total >= 1000000)
			{
				cout << staffs[(*staffs_it).first].num << endl;
				over1000000++;
			}
			staffs_it++;
		}
		if(over1000000 == 0) cout << "NA" << endl;
	}
}	