#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(void) {
    int n, e, flag = 0;
    ll p, q;

    while (scanf("%d", &n), n) {
        vector<int> v;
        map<int, ll> mp;
        for (int i = 0; i < n; i++) {
            scanf("%d %lld %lld", &e, &p, &q);
            if (!mp[e]) v.push_back(e);
            mp[e] += p * q;
        }

        flag = 0;
        for (int i = 0; i < v.size(); i++) {
            if (mp[v[i]] < 1000000) continue;
            printf("%d\n", v[i]);
            flag = 1;
        }
        
        if (!flag) puts("NA");
    }
    return 0;
}
