#include<iostream>
using namespace std;

int main()
{
	int num, man, yen, ko;
	int c;
	int p[10] = {};
	
	while (1){
		c = 0;

		cin >> num;
		if (!num)	break;

		for (int i = 0; i < num; i++){
			int j = i;
			cin >> man >> yen >> ko;

			if (yen * ko >= 1000000){
				for (; j > 0; j--){
					if (p[j - 1] == man)
						man = 0;
				}
				if (man != 0){
					p[i] = man;
					cout << man << endl;
					c++;
				}
			}
		}

		if (c == 0)
			cout << "NA" << endl;
	}

	return 0;
}