#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;

int main() {
	int num;						//1???????????????????????\????????°
	int data_set = 0;				//???????????????????????°
	bool do_continue = true;		//??????????????°
	std::vector<string> result;		//??????

	while (do_continue) {
		cin >> num;		//???????????°??\???
		if ((num == 0) || (data_set > 50)) {
			do_continue = false;
		}
		else {
			bool na_flg = true;				//NA????????°
			data_set++;						//?????????????????????
			std::map<int, int> e;			//??????
			std::vector<int> employee;
			int fst, snd, thd;

			for (int i = 0; i < num; i++) {
				cin >> fst >> snd >> thd;
				employee.push_back(fst);
				//????????????????????´???
				if (e.count(employee[i])) {
					e[employee[i]] += snd * thd;
				}
				//??°???????????????
				else {
					e[employee[i]] = snd * thd;
				}
			}

			//1000000??\???????????????????´?
			for (unsigned int j = 0; j < employee.size(); j++) {
				if (e[employee[j]] >= 1000000) {
					na_flg = false;
					result.push_back(std::to_string(employee[j]));
				}
			}

			//NA??????
			if (na_flg) {
				result.push_back("NA");
			}
		}
	}

	for (unsigned int i = 0; i < result.size()-1; i++) {
		cout << result[i] << endl;
	}

	//while (1);

	return 0;
}