#include<iostream>
using namespace std;

#define MAX_EMPLOYEE 4000

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

                double salesOfEmployee[MAX_EMPLOYEE+1];
                for(int i=0; i<=MAX_EMPLOYEE; i++) salesOfEmployee[i]=0;
                
                int id;
                double price, quantity;
                for(int i=0; i<n; i++){
                        cin >> id >> price >> quantity;
                        salesOfEmployee[id] += price*quantity;
                }
                
                int flag = 0;
                for(int i=1; i<=MAX_EMPLOYEE; i++){
                        if( salesOfEmployee[i] >= 1000000 ){
                                cout << i << endl;
                                flag = 1;
                        }
                }
                if( !flag ) cout << "NA\n";
        }

        return 0;
}