#include<cstdio>
#include<vector>

using namespace std;
const int target = 1000000;
vector<int> heros;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			int num, sell, cnt;
			scanf("%d %d %d", &num, &sell, &cnt);
			if (sell*cnt >= target)
			{
				bool already = false;
				for (int j = 0; j < heros.size(); j++)
				{
					if (heros[j] == num)
						already = true;
				}
				if (already == false)
				{
					printf("%d\n", num);
					heros.push_back(num);
					hero = true;
				}
			}
		}
		if (hero==false)
			printf("NA\n");
	}
	return 0;
}