#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll sums[4000];
bool used[4000];
int main()
{
	int n;
	while(cin>>n,n) 
	{
		bool f=false;
		int num;
		int a,b;
		fill(sums,sums+4000,0);
		fill(used,used+4000,0);
		for(int i = 0; i < n; ++i)
		{
			cin>>num>>a>>b;
			sums[num-1]+=a*b;
			used[num-1]=true;
		}
		for(int i = 0; i < 4000; ++i)
		{
			if(used[i]&&sums[i]>=1000000)
			{
				cout<<i+1<<endl;
				f=true;
			}
		}
		if(!f) cout<<"NA"<<endl;
	}
  return 0;
}