#include <iostream>
#include <vector>
#include <queue>

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