#include <iostream>
#include <cstring>
#define STA 1000000
using namespace std;

int main(){
    int n;
    long long num,price,value;
    long long total[4001]={0};
    bool judge;
    while(1){
        memset(total,0,sizeof(total));
        cin >> n;
        if(n == 0) break;
        judge = false;
        while(n--){
            cin >> num >> price >> value;
            total[num] += price * value;
        }
        for(int i=1;i<=4001;i++){
            if(total[i] >= STA){
                cout << i << endl;
                judge = true;
            }
        }
        if(!judge) cout << "NA" << endl;
    }
}