#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define INF 10000000
#define MAX_N 4001

int n;
int meibo[MAX_N];

struct kanri{

	int number;
	long long sum;

}syain[MAX_N];

void shoki();

int main(){

	while(true){
	
		scanf("%d", &n);

		if(n == 0)
			break;

		shoki();

		int num = 0;
		int kari;

		for(int i = 0; i < n; i++){
			scanf("%d", &kari);
			bool flag = false;
			for(int j = 0; j < num; j++){
				if(syain[j].number == kari){
					int kari1, kari2;
					scanf("%d%d", &kari1, &kari2);
					syain[j].sum += kari1*kari2;
					flag = true;
					break;
				}
			}

			if(!flag){
				int kari1, kari2;
				syain[num].number = kari;
				scanf("%d%d", &kari1, &kari2);
				syain[num].sum += kari1 * kari2;
				num++;
			}

		}

		bool flag2 = false;

		for(int i = 0; i < n; i++){
			if(syain[i].sum >= 1000000){
				printf("%d\n", syain[i].number);
				flag2 = true;
			}
		}

		if(!flag2){
			printf("NA\n");
		}

	
	}


	return 0;

}

void shoki(){
	for(int i = 0; i < MAX_N; i++){
		syain[i].number = 0;
		syain[i].sum = 0;
	}
}