#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;

    while (cin >> n) {
        if (!n)
            break;

        int id, p, q;
        bool flag = false;
        long long workers[4000] = {0};
        for (int i = 0; i < n; i++) {
            cin >> id >> p >> q;
            workers[id] += p * q;
        }

        for (int i = 0; i < 4000; i++) {
            if (workers[i] >= 1000000) {
                cout << i << endl;
                flag = true;
            }
        }
        if (!flag)
            cout << "NA" << endl;
    }

    return 0;
}