#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        map<int, long long> m;
        int i;
        long long p, q;
        for (int k=0; k<n; ++k) {
            cin >> i >> p >> q;
            m[i] += p * q;
        }
        bool na = true;
        for (auto it=m.begin(); it!=m.end(); ++it) {
            if (1000000LL <= it->second) {
                cout << it->first << endl;
                na = false;
            }
        }
        if (na) cout << "NA" << endl;
    }
    return 0;
}