#include <iostream>
#define  N    4000
using namespace std;

struct sale{
	long price;
	long num;
};

int main(){

	while(1){
		int n, cost, piece, num, count = 0;
		cin>>n;
		if(n == 0)
			break;

		sale a[N];
		for(int i=0;i<N;i++){
			a[i].price = 0;
			a[i].num = 0;
		}

		for(int i=0;i<n;i++){
			cin>>num>>cost>>piece;
			a[num-1].price += cost;
			a[num-1].num   += piece;
		}

		for(int i=0;i<N;i++){
			if(a[i].price * a[i].num >= 1000000){
				cout<<i+1<<endl;
				count++;
			}
		}

		if(count == 0)
			cout<<"NA"<<endl;
	}

	return 0;
}