#include<iostream>
#include<vector>
using namespace std;
int  existnum(vector<int> v,int e){
    for(int i=0;i<v.size();i++){
        if(v[i]==e)return i;
    }
    return -1;
}

int main(void){
    int n,b=0,e,p,q,num;
    vector<int> se,sp,sq;
    while(1){
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>e;
            cin>>p;
            cin>>q;
            if((num=existnum(se,e))!=-1){
                sp[num]+=p;
                sq[num]+=q;
            }else{
                se.push_back(e);
                sp.push_back(p);
                sq.push_back(q);
            }
        }
        for(int i=0;i<n;i++){
            if(sp[i]*sq[i]>=1000000){
                cout<<se[i]<<endl;
                b=1;
            }
        }
        if(b==0){
            cout<<"NA"<<endl;
        }
        sp.clear();
        se.clear();
        sq.clear();
        b=0;
    }
    return 0;
}
