#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    int n;
    while(cin>>n, n!=0) {
        int memo[4000] = {0};
        for(int i=0; i<n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            memo[a] += (b*c);
        }
        int ans = 0;
        for(int i=0; i<4000; ++i) {
            if(memo[i]>=1000000) {
                cout << i << endl;
                ans++;
            }
        }
        if(ans==0) cout << "NA" << endl;
    }
    return 0;
}