#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;


int main(){

	long long int sales[4001],price,amount;

	int n,id,count;

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

		for(int i = 1; i <= 4000; i++)sales[i] = 0;

		for(int i = 1; i <= n; i++){
			scanf("%d %lld %lld",&id,&price,&amount);
			sales[id] += price*amount;
		}

		count = 0;

		for(int i = 1; i <= 4000; i++){
			if(sales[i] >= 1000000){
				printf("%d\n",i);
				count++;
			}
		}
		if(count == 0)printf("NA\n");
	}

    return 0;
}