#include <stdio.h>

typedef struct
{
	unsigned int id;
	unsigned long long total;
}info;

info s_info[4000];

int main()
{
	unsigned int i;
	unsigned int data_num;

	/* ????????? */
	for (i = 0; i < 4000; i++)
	{
		s_info[i].id = 0;3
		s_info[i].total = 0;
	}


	while (1)
	{
		unsigned int clear = 0;
		unsigned long long uri;
		unsigned long long kazu;

		scanf("%d", &data_num);

		if (data_num == 0)
		{
			break;
		}

		for (i = 0; i<data_num; i++)
		{
			scanf("%d %lld %lld", &s_info[i].id, &uri, &kazu);

			/* id?????????scanf?????§ */
			/* ?£????????????? */
			s_info[i].total = uri * kazu;
		}

		for (i = 0; i < data_num; i++)
		{
			if (s_info[i].total >= 1000000)
			{
				printf("%d\n", s_info[i].id);
				clear++;
			}
		}

		if (clear == 0)
		{
			printf("NA\n");
		}
	}

	return 0;

}