#include <iostream>
#include <map>
#include <vector>
#include <set>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		set<int> Set;
		vector<int> num;
		map<int, unsigned long long int> Map;
		while(n--)
		{
			unsigned long long int a, b, c;
			cin >> a >> b >> c;
			if(Set.find(a) == Set.end())
			{
				num.push_back(a);
			}
			Set.insert(a);
			Map[a] += b * c;
		}
		bool exist_flag = false;
		for(int i = 0; i < num.size(); ++i)
		{
			if(Map[num[i]] >= 1000000)
			{
				cout << num[i] << endl;
				exist_flag = true;
			}
		}
		if(!exist_flag)
		{
			cout << "NA" << endl;
		}
	}
}

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