#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n;
    while( cin >> n, n ){
        vector< long long int > ls(4001, 0);
        bool NA = true;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            if( ls[a] >= 0 ){
                ls[a] += b*c;
                if( ls[a] >= 1000000){
                    cout << a << endl;
                    NA = false;
                    ls[a] = -1;
                }
            }
        }
        if( NA ) cout << "NA" << endl;
    }
    return 0;
}