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

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int n; ll en, price, qty, check[4001]; qi que;

int main()
{
    while(cin >> n && n) {
       if (n == 0) break;
       
       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);
               check[en]=-1;
           }
       }
        
       if (que.empty()) cout << "NA" << "\n";
       else {
           for(int i=0,len=que.size(); i < len; ++i) {
               cout << que.front() << "\n";
               que.pop();
           }
       }
    }

    return 0;
}