#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, id, p, q;
    while (cin >> n && n) {
        map<int, int> ids;
        vector<pair<int, long long>> sum;
        for (int i=0; i<n; ++i) {
            cin >> id >> p >> q;
            if (ids.count(id)) {
                sum[ids[id]].second += p * q;
            } else {
                sum.push_back(make_pair(id, p * q));
                ids[id] = sum.size() - 1;
            }
        }
        bool na = true;
        for (auto x : sum) {
            if (1000000 <= x.second) {
                cout << x.first << endl;
                na = false;
            }
        }
        if (na) {
            cout << "NA" << endl;
        }
    }

    return 0;
}