#include <iostream>
using namespace std;
typedef long long ll;
ll a[4001];

int main(){
	int n, num, p, q;
	while(cin >> n, n){
		fill(a, a+4001, 0);
		int f = 1;
		
		for(int i = 0;i < n;i++){
			cin >> num >> p >> q;
			a[num] += p * q;
			if(a[num]>999999)cout << num << endl, f = 0;
		}
		
		if(f)cout << "NA" <<endl;
	}
	return 0;
}