#include <iostream>
#include <cstdio>
#define X 4001
#define V 1000000
using namespace std;

int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int a[X];
		for(int i=0;i<X;i++) a[i] = 0;
		int b,c,d;
		for(int i=0;i<n;i++){
			cin >> b >> c >> d;
			if(a[b]<V) a[b] += c*d;
		}
		bool e = true;
		for(int i=0;i<X;i++){
			if(a[i]>=V){
				e = false;
				cout << i << endl;
			}
		}
		if(e) cout << "NA" << endl;
	}
}