#include <bits/stdc++.h>

using namespace std;

int main(){

  int n, id, val, num;
  int member[4000];

  while(cin >> n){

    if(!n) break;

    memset(member, 0, sizeof(member));

    for(int i = 0; i < n; ++i){
      cin >> id >> val >> num;
      member[id - 1] += val * num;
    }

    bool flag = false;

    for(int i = 0; i < 4000; ++i){
      if(member[i] >= 1000000){
        cout << i + 1 << endl;
        flag = true;
      }
    }

    if(!flag) cout << "NA" << endl;

  }

}