#include<algorithm>
#include<iostream>
#include<vector>
#include<stdio.h>
struct su{
	int num;
	int sum;
}p[4001];
using namespace std;
int main()
{
	int n,i2;
	int sn,x, y,l=0;
	while (1){
		l = 0;
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			for (i2 = 0; i2 < l; i2++){
				if (p[i2].num == sn){
					p[i2].sum += x*y;
					break;
				}
			}
			if (i2 == l){
				p[l].sum = 0;
				p[l].num = sn;
				p[l].sum += x*y;
				l++;
			}
		}
		int maxn = 0;
		int maxc = 0;
		for (int i = 0; i < l; i++){
			if (maxn < p[i].sum){
				swap(maxn, p[i].sum);
				maxc = p[i].num;
			}
		}
		if (maxn >= 1000000){
			cout << maxc << endl;
		}
		else
			cout << "NA" << endl;
	}
}