#include <vector>
#include <iostream>

using namespace std;

int main()
{
	int N, X, Y, Z;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		vector<long long> P(4001);

		for (int i = 0; i < N; i++)
		{
			cin >> X >> Y >> Z;

			P[X] += (long long)Y * Z;
		}

		int count_ = 0;

		for (int i = 1; i <= 4000; i++)
		{
			if (P[i] >= 1000000)
			{
				cout << i << endl; count_++;
			}
		}

		if (!count_)
		{
			cout << "NA" << endl;
		}
	}

	return 0;
}