#include <iostream>
#include <vector>

int main() {
	int n;
	std::cin >> n;
	while (n != 0) {
		bool flag{ true };
		std::vector<int> crue(4000 + 1, 0);
		for (auto i = 0; i < n; ++i) {
			int id, value, size;
			std::cin >> id >> value >> size;
			crue.at(id) += value * size;
		}
		for (auto i = 1; i <= 4000; ++i) {
			if (crue.at(i) >= 1000000) {
				std::cout << i << "\n";
				flag = false;
			}
		}
		if (flag) {
			std::cout << "NA\n";
		}
		std::cin >> n;
	}
	return 0;
}