#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct{
    int id;
    int cost;
    int amount;
    int sum;
}employee;

int main(){
    employee getinp;
    int n;
    while(cin >> n,n){
        vector<employee> emps;
        for (int i=0;i<n;i++){
            cin >> getinp.id >> getinp.cost >> getinp.amount;
            getinp.sum=getinp.cost*getinp.amount;
            if(emps.empty()) emps.push_back(getinp);
            else{
                for(int j=0;j<emps.size();j++){
                    if(emps[j].id==getinp.id) {
                        emps[j].sum+=getinp.sum;
                        break;
                    }else if(j==emps.size()-1){
                        emps.push_back(getinp);
                        break;
                    }
                }
            }
        }
        int* ids=new int[emps.size()];
        int j=0;
        for (int i=0;i<emps.size();i++){
            if (emps[i].sum>=1000000){
                ids[j]=emps[i].id;
                j++;
            }
        }
        sort(ids,ids+j);
        if(j==0) cout << "NA" << endl;
        else{
            for(int i=0;i<j;i++){
                cout<<ids[i]<<endl;
            }
        }
        delete ids;
    }
    return 0;
}