#include <iostream>
using namespace std;
int main(){
    long long bangou,tanka,kosuu;
    long long number; cin >> number;
    long long kuso[number];
    do{
        long long man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            kuso[i]=0;
        }

        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
            kuso[i]=bangou;
        }
        int count =0;
        if(man[kuso[0]-1]>=1000000){
            cout << kuso[0] << endl;
            count++;
        }
        for(int i=1;i<number;i++){
            int tmp =0;
            for(int j=0;j<i;j++){
                if(kuso[i]==kuso[j]){
                    tmp++;
                    break;
                }
            }
            if(tmp==0 && man[kuso[i]-1]>=1000000){
                cout << kuso[i] << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}