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

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