#include <iostream>
#include <map>

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		map<int, unsigned long long int> Map;
		bool Flag = false;
		unsigned long long int a, b, c;
		for(int i = 0; i < N; ++i)
		{
			cin >> a >> b >> c;
			Map[a] += b * c;
		}
		for(map<int, unsigned long long int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
		{
			if(Ite->second >= 1000000)
			{
				cout << Ite->first << endl;
				Flag = true;
			}
		}
		if(!Flag)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}