#include <stdio.h>

int main(void)
{
	__int64 member[4000], unit, num;
	int n, i, number, f;
	
	while (scanf("%d", &n), n != 0){
		f = 0;
		for (i = 0; i < 4000; i++){
			member[i] = 0;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d %I64d %I64d", &number, &unit, &num);
			member[number - 1] += (unit * num);
		}
		
		for (i = 0; i < n; i++){
			if (member[i] >= 1000000){
				printf("%d\n", i + 1);
				f = 1;
			}
		}
		
		if (f == 0){
			printf("NA\n");
		}
	}
	
	return (0);
}