#include <iostream>
using namespace std;

class CMem {
public :
	CMem() { m_sale = 0; m_rank = 0; m_mill = false; }
	void Idata(long long sale);
	void ONmill() { m_mill = true; }
	bool Irank(int rank);
	int Orank() { return m_rank; }
	bool Omill() { return m_mill; }
private :
	bool m_mill;
	long long m_sale;
	int m_rank;
};

void CMem::Idata(long long sale) {
	if(m_mill == false) {
		m_sale += sale;
		if(m_sale >= 1000000) {
			m_mill = true;
		}
	}
}

bool CMem::Irank(int rank) {
	if(m_rank == 0) {
		m_rank = rank;
		return true;
	}
	else {
		return false;
	}
}

int main(void)
{
	while(1) {
		CMem member[4001];
		bool NA = true;
		int n, id, rank = 1, mrank;
		long long asale, scale, sale;

		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; i++) {
			cin >> id >> asale >> scale;
			sale = asale * scale;

			if(member[id].Irank(rank) == true) { rank++; }
			if(sale >= (long long)1000000) { member[id].ONmill(); }
			else { member[id].Idata(sale); }
		}

		mrank = rank - 1;

		for(rank = 1; rank <= mrank; rank++) {
			for(int i = 1; i <= 4000; i++) {
				if(member[i].Orank() == rank && member[i].Omill() == true) {
					cout << i << endl;
					NA = false;
				}
			}
		}

		if(NA == true) cout << "NA" << endl;
	}
	return 0;
}