#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    map<int, long> mp;
    vector<int> vec;
    while (cin >> n && n != 0) {
        for (int i = 0; i < n; i++) {
            int id;
            long p, q;
            cin >> id >> p >> q;
            mp[id] += p * q;
        }
        for (auto m : mp)
            if (m.second >= 1000000) vec.push_back(m.first);

        if (vec.size() == 0)
            cout << "NA" << endl;
        else {
            for (auto v : vec) cout << v << endl;
        }

        mp.clear();
        vec.clear();
    }
    return EXIT_SUCCESS;
}