#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,id,f=0;
	ll price,num;
	cin >> n;
	if (n==0)break;
	rep(i,n)
	{
	    cin >> id >> price >> num;
	    if (price*num >= 1000000)
	    {
		cout << id << endl;
		f=1;
	    }
	}
	if (f==0)cout << "NA" << endl;
    }
    return 0;
}