#include <iostream>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define ll long long

int main()
{
    while (1)
    {
	int n,f=0,id;
	ll price,num,p[4000];
	rep(i,4001)p[i]=0;
	cin >> n;
	if (n==0)break;
	rep(i,n)
	{
	    cin >> id >> price >> num;
	    p[id]+=price*num;
	}
	rep(i,4001)
	{
	    if (p[i] >= 1000000)
	    {
		f=1;
		cout << i << endl;
	    }
	}
	if (f==0)cout << "NA" << endl;
    }
    return 0;
}