# include <iostream>
# include <vector>
# include <cstring>

int n;
int a[3];
std::vector<std::pair<int, int>> vec;
bool x[4001];

int main() {
	while (1) {
		std::cin >> n;
		if (n == 0)
			break;
		int count = 0;
		vec.clear();
		std::memset(x, false, sizeof(x));

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j)
				std::cin >> a[j];
			if (x[a[0]]) {
				for (int k = 0; k < vec.size(); ++k) {
					if (vec[k].first == a[0])
						vec[k].second += a[1] * a[2];
				}
			}
			else {
				vec.push_back(std::make_pair(a[0], a[1] * a[2]));
				x[a[0]] = true;
			}
		}
		for (auto it = vec.begin(); it != vec.end(); ++it) {
			if ((*it).second >= 1000000) {
				std::cout << (*it).first << std::endl;
				++count;
			}
		}
		if (count==0)
			std::cout << "NA" << std::endl;
	}
	return 0;
}