#include<iostream>
using namespace std;
int main()
{
    int n,na,e;
    long long sum[4010];
    long long p,q;
    while(cin >> n,n!=0){
        na = 0;
        for(int i=0;i<=4000;i++) sum[i] = 0;
        for(int i=0;i<n;i++){
            cin >> e >> p >> q;
            if(sum[e] >= 1000000) continue;
            sum[e] += p*q;
            if(sum[e] >= 1000000){
                na = 1;
                cout << e << endl;
            }
        }
        if(na == 0) cout << "NA" << endl;
    }
    return 0;
}

