#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);

    vector<int> sum(4001, 0);
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;

        fill(sum.begin(), sum.end(), 0);
        for (int i=0; i<n; ++i) {
            int no, price, quantity;
            cin >> no >> price >> quantity;
            sum[no] += price * quantity;
        }

        bool NA = true;
        for (int i=1; i<=4000; ++i) {
            if (sum[i] >= 1000000) {
                cout << i << endl;
                NA = false;
            }
        }
        if (NA) {
            cout << "NA" << endl;
        }
    }

    return 0;
}