#include <iostream>
#include <queue>
using namespace std;

const int lim = 1000000;
bool flag;

int main()
{
    int n, en, price, qty;

    while(cin >> n && n) {
        long long check[4001] = {0}; queue<int> que;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= 0) check[en] += price*qty;
            if (check[en] >= lim) {
                que.push(en);
                flag=true;
                check[en]=-1;
            }
        }

        if (flag) {
            while(!que.empty()) {
                cout << que.front() << endl;
                que.pop();
            }
        } else cout << "NA" << endl;
    }

    return 0;
}