#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        map<int, long long> info;
        map<int, long long>::iterator it;
        rep(i,n){
            int a, b, c;
            cin >> a >> b >> c;
            info[a] += b * c;
        }
        bool c = true;
        for(it = info.begin(); it != info.end(); it++){
            if(it->second >= 1000000){
                cout << it->first << endl;
                c = false;
            }
        }
        if(c) cout << "NA" << endl;
    }
}