#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MAX_N = 4000;

int n, e, p, q;
ll a[MAX_N];

int main(){
	while(1){
		for(int i = 0; i < MAX_N; i++){
			a[i] = 0;
		}
		cin >> n;
		if(n == 0) break;
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			e--;
			a[e] += p * q;
		}
		bool def = false;
		for(int i = 0; i < MAX_N; i++){
			if(a[i] >= 1000000LL){
				cout << i + 1 << endl;
				def = true;
			}
		}
		if(def == false) cout << "NA" << endl;
	}
	return 0;
}