/*
#include<stdio.h>
int main(void)
{
	int ct,num[4001],tanka[4001],kosu[4001],many[4001];
	while(scanf("%d",&ct)){
		if(ct==0){
			return 0;
		}
		for(int f1=0;f1<ct;f1++){
			scanf("%d %d %d",&num[f1],&tanka[f1],&kosu[f1]);
			many[f1]=tanka[f1]*kosu[f1];
		}
		for(int f1=0;f1<ct;f1++){
			for(int f2=0;f2<ct;f2++){
				if((num[f1]==num[f2])&&f1!=f2){
					many[f1]=many[f1]+many[f2];
					num[f2]=-1;
				}
			}
		}
		int flg=0;
		for(int f1=0;f1<ct;f1++){
			if(many[f1]>=1000000){
				printf("%d\n",num[f1]);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}
*/
#include <iostream>
#include <vector>
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<int, bool> IB;

struct P{
	int id;
	int tanka;
	int kosuu;
};

ll shain[4001];
bool used[4001];
bool more[4001];

int main()
{
	int n;

	while (cin >> n && n ){
		memset (shain, 0LL, sizeof (shain ) );
		memset (used, false, sizeof (used ) );
		memset (more, false, sizeof (more ) );
		vector<P> data (n );

		rep (i, n )
			cin >> data[i].id >> data[i].tanka >> data[i].kosuu;

		rep (i, n ){
			ll total = (ll)data[i].tanka*(ll)data[i].kosuu;
			shain[data[i].id] += total;
		} // end if

		for (int i = 1; i <= 4000; i++ )
			if (shain[i] >= 1000000LL )
				more[i] = true;

		bool found = false;
		rep (i, n ){
			if (more[data[i].id] && !used[data[i].id] ){
				cout << data[i].id << endl;
				used[data[i].id] = true;
				if (!found )
					found = true;
			} // end if
		} // end rep

		if (!found )
			cout << "NA" << endl;
	} // end loop
		
	return 0;
}