#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
using namespace std;
int main() {
	int n;
	while (true) {
		map<int,int> dp;
		scanf("%d", &n);
		if (n == 0) break;
		bool neko = false;
		for (int i = 0;i < n;++i) {
			long long a, b, c;
			scanf("%lld%lld%lld", &a, &b, &c);
			if (b*c+dp[a] >= 1000000&&dp[a] < 99999999) {
				printf("%d\n", a);
				neko = true;
				dp[a] = 9999999999;
			}
			else {
				dp[a] += b*c;
			}
		}
		if (neko == false)printf("NA\n");
	}
}
