#include <iostream>

int main()
{
	const int threshold = 1000000;
	int n;
	
	while (std::cin >> n, n) {
		bool naFlag = true;
		while (n--) {
			int id;
			//__int64 unit, quantity;
			long long unit, quantity;
			std::cin >> id >> unit >> quantity;
			
			if (unit * quantity >= threshold)  {
				naFlag = false;
				std::cout << id << std::endl;
			}
		}
		if (naFlag) std::cout << "NA" << std::endl;
	}
	
	return 0;
}