#include <iostream>

using namespace std;

//empoyer,price,quantity;
int main()
{
    
    while (1){
        int num;
        cin >> num;
        if (num == 0) break;
        int employer[4001][2] = {0};
        
        int e, p, q;
        int ans[4001] = {0};
        for (int i = 0; i < num; i++) {
            cin >> e >> p >> q;
            ans[i] = e;
            employer[e][0] = employer[e][0] + (p * q);
            if (employer[e][0] >= 1000000) {
                employer[e][1] = 1;
            }
        }
        bool answer = true;
        for (int i = 0; i < num; i++ ) {
            if (employer[ans[i]][1] == 1) {
                cout << ans[i] << endl;
                employer[ans[i]][1] = -1;
                answer = false;
            }
        }
        if (answer) cout << "NA" << endl;
    }
    return 0;
}