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

int main(){
    int n;
    long long num,price,value;
    bool judge;
    while(1){
        cin >> n;
        if(n == 0) break;
        map <int,long long> data;
        map <long long,long long> data1;
        map <long long,long long>::iterator itr;
        data.clear();
        data1.clear();
        for(int i=1;i<=n;i++){
            cin >> num >> price >> value;
            itr = data1.find(num);
            if(itr != data1.end()) data1[num] += price * value;
            else {
                data.insert(map<int,long long>::value_type(i,num));
                data1.insert(map<long long,long long>::value_type(num,price*value));
            }
        }
        judge = false;
        for(int i=1;i<=n;i++){
            if(data1[data[i]] >= STA){
                cout << data[i] << endl;;
                judge = true;
            }
        }
        if(!judge) cout << "NA" << endl;
    }
}