#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

li shine[4040];
li submit[4040];

int main(){
	li n;
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,4040)shine[i]=0;
		rep(i,4040)submit[i]=0;
		vector<li> jun;
		rin{
			li a1,a2,a3;
			cin>>a1>>a2>>a3;
			shine[a1]+=a2*a3;
			jun.pb(a1);
		}
		bool ita=false;
		rep(i,sz(jun)){
			if(shine[jun[i]]>=1000000 && submit[jun[i]]==0){
				submit[jun[i]]=1;
				cout<<jun[i]<<endl;
				ita=true;
			}
		}

		if(!ita)puts("NA");
	}

	return 0;
}