#include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		int company[4000] = { 0 };
		int num, sell, cnt;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			company[num - 1] += sell*cnt;
			if (company[num - 1] >= target)
			{
				printf("%d\n", num);
				company[num - 1] = -1000000000;
			}
		}

		if (hero == false)
			printf("NA\n");
	}
	return 0;
}