#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long int ll;

int main()
{
    for(;;){
		ll n,num,pr,co;
		cin >> n;
		if(n==0)return 0;
		ll a[4000];
		for(int i=0;i<4000;i++)a[i]=0;
		for(int i=0;i<n;i++){
			cin >> num >> pr >> co;
			a[num-1]+=pr*co;
		}
		bool f=true;
		for(int i=0;i<4000;i++){
			if(a[i]>=1000000){
				printf("%d\n",i+1);
				f=false;
			}
		}
		if(f)printf("NA\n");
	}
    return 0;
}