#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <map>
using namespace std;
ifstream fin("D:\\txt.txt");
#define for0(i,n) for (i=0;i<n;i++)
map<int,int> data;
#define MV(a,b) map<int,int>::value_type(a,b) 

int main()
{
	int n,a,b,c,i,j;
	while(cin>>n)
	{
		data.clear();
		if(!n)break;
		for0(i,n)
		{
			cin>>a>>b>>c;
			c*=b;
			if (data.find(a)==data.end())
			{
				data.insert(MV(a,c));
			}
			else
			{
				data[a]+=c;
			}
		}

		map<int,int>::iterator it=data.begin();
		bool bo=true;
		while(it!=data.end())
		{
			if (1000000<=it->second)
			{
				cout<<it->first<<endl;
				bo=false;
			}
			it++;
		}
		if (bo)
		{
			cout<<"NA"<<endl;
		}
	}
	return 0;
}//*/