#include <iostream>
#include <utility>
using namespace std;

int n;
pair<int, int> ans;

int solve(int n){
        int id,p,q,sales[10000]={};
        for(int i=0;i<n;i++){
                cin >> id;
                cin >> p;
                cin >> q;
                sales[id] += p*q;
        }
        ans.first = 0;
        ans.second = 0;
        for(int i=0;i<10000;i++){
                if(ans.second < sales[i]){
                        ans.first = i;
                        ans.second = sales[i];
                }
        }
        if(ans.second < 1000000){
                cout << "NA" << endl;
        }else {
                cout << ans.first << endl;
        }
}

int main(){
        while(1){
                cin >> n;
                if(n == 0) break;

                solve(n);
        }
}