#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
long long int sales[4010];
#define foreach(r,p,it) for(r::iterator it=p.begin();it!=p.end();++it)

int main()
{
    int n;
    while(cin>>n)
    {
        vector<int> shains;
        if(n==0)break;
    
        memset(sales,0,sizeof(sales));
        int num,tanka,kazu;

        for(int i=0;i<n;i++)
        {
            cin>>num>>tanka>>kazu;
            sales[num] += tanka*kazu;
            int f=0;
            foreach(vector<int>,shains,it)
            {
                if(*it == num){f=1;break;}
            }
            if(f==0) shains.push_back(num);
        }
        int na = 0;
        foreach(vector<int>,shains,it)
        {
            if(sales[*it] >= 1000000){cout<<*it<<endl;na=1;}
        }
        if(na==0)cout<< "NA"<<endl;
    }
    return 0;
}