#include<iostream>
using namespace std;
int ans[4000];

int main(){
	int N;
	int e, p, q;
	int x;
	while (1){
		x = 0;
		cin >> N;
		if (N == 0)break;
		while (N){
			cin >> e >> p >> q;
			if (p*q < 1000000){
				ans[x] = e;
				x++;
			}
			N--;
		}
		if (ans[0] == 0)cout << "NA" << endl;
		else for (int i = 0; i < N; i++){
			if (ans[x] == 0)break;
			cout << ans[x] << endl;
		}
	}
	return 0;
}