#include<map>
#include<iostream>
using namespace std;
int main()
{
    map<int,int> total;

	int d,num,item,ko,cont=0;
	bool ok;

	while(cin>>d, d)
	{
		for(int i=0;i<d;i++)
		{
			cin>>num>>item>>ko;
			item *= ko;
			if(total.count(num))
			{
				total[num] += item;
			}
			else
			{
				total.insert(make_pair(num, item));
			}
		}

		ok = false;
		map<int,int>::iterator it;
		for(it = total.begin(); it != total.end(); it++)
		{
			if((*it).second >= 1000000)
			{
				cout << (*it).first <<endl;
				ok = true;
			}
		}

		if(ok == false)
		{
			cout<<"NA"<<endl;
		}
		
		total.clear();
	}
}