#include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n;
	int x = 0;
	std::vector<int> A;
	while (std::cin >> n, n != 0) {
		int z = 0;
		++x;
		std::vector<int> m(n);
		std::vector<std::vector<int>> V(n, std::vector<int>(3));
		for (int i = 0;i < n;++i) {
			for (int j = 0;j < 3;++j) {
				std::cin >> V[i][j];
			}
		}
		for (int i = 0;i < n;++i) {
			m[i] = V[i][1] * V[i][2];
		}
		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;++j) {
				if (i < j) {
					if (V[i][0] == V[j][0]) {
						m[i] += m[j];
						m[j] = 0;
					}
				}
			}
		}
		for (int i = 0;i < n;++i) {
			if (m[i] >= 1000000) {
				std::cout << V[i][0] << std::endl;
				z = 1;
			}
		}
		if (z == 0) {
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}