int main() {
	int i, j, n, num, val, sell, flag;

	while (1) {
		flag = 0;
		int total[4000] = {};

		scanf("%d", &n);
		if (n == 0) {
			break;
		}

		for (i = 0; i < n; i++) {
			scanf("%d", &num);
			scanf("%d", &val);
			scanf("%d", &sell);

			total[num] += val * sell;
		}

		for (j = 0; j < 4000; j++) {
			if (total[j] >= 1000000) {
				printf("%d\n", j);
				flag = 1;
			}
		}

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

	return 0;
}