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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n;
    while (cin >> n, n) {
        vector<ll> s(4000, 0);
        REP(i,n) {
            int e,p,q;
            cin >> e >> p >> q;
            s[e-1] += p*q;
        }
        bool flag = false;
        REP(i,4000) {
            if (s[i] >= 1000000) {
                cout << i + 1 << endl;
                flag = true;
            }
        }
        if (!flag) cout << "NA" << endl;
    }
    return 0;
}
