#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};
        int count = -1;
        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) {
                employer[e][1] = 1;
                count++;
                ans[count] = e;
            }
        }
        if (count >= 0) {
            for (int i = 0; i <= count; i++) {
                cout << ans[i] << endl;
            }
        }else {
            cout << "NA" << endl;
        }
    }
    return 0;
}