#include <iostream>
#include <cstring>

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

using namespace std;

int main()
{
	long long int value[4001];

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

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

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

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