#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, i, p, q;
    while(cin >> n && n) {
        bool isExist = false;
        map<int, long long int> emp;
        rep(l, n) {
            cin >> i >> p >> q;
            if(emp[i] != -1) {
                emp[i]+=p*q;
                if(emp[i] >= 1000000) {
                    cout << i << endl;
                    emp[i] = -1;
                    isExist = true;
                }
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}