#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	long long value[4001];
	vector<long long> v;

	int n,num,k,m;
	while(cin >> n && n)
	{
		memset(value,0,sizeof(value));
		v.clear();

		rep(i,n)
		{
			cin >> num >> k >> m;
			value[num] += k*m;

			vector<long long>::iterator ite = find(v.begin(),v.end(),num);
			if(ite == v.end())
			{
				v.push_back(num);
			}
		}

		bool flag = true;
		rep(i,v.size())
		{
			if(value[v[i]] >= 1000000)
			{
				flag = false;
				cout << v[i] << endl;
			}
		}

		if(flag) cout << "NA" << endl;
	}
	return 0;
}