#include <iostream>

using namespace std;

int main(){

	int i, j = 0;

	while(true){
		int n;

		cin >> n;

		if(n == 0){
			cout << "NA" << endl;
			break;
		}
		else if(n < 0 || 4000 < n){
			continue;
		}
		int* a = new int[n];
		int* b = new int[n];
		int* c = new int[n];

		for(i = 0; i < n; i++){
			cin >> a[i] >> b[i] >> c[i];
		}

		for(i = 0; i < n; i++){
			if(b[i] * c[i] >= 1000000){
				cout << a[i] << endl;
				j++;
			}
		}
		if(j == 0){
			cout << "na" << endl;
		}


	}
}