#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		set <int> T;
		bool flag = true;
		while ( n-- )
		{
			int no;
			long long p, q;
			cin >> no >> p >> q;

			if ( T.find( no ) == T.end() && p * q >= 1000000 )
			{
				flag = false;
				cout << no << endl;
				T.insert( no );
			}
		}

		if ( flag )
			cout << "NA\n";
	}
	return 0;
}