#include <iostream>
using namespace std;
 
int main(){
  double n ,flag=0 ,num[4001] ,price[4001] ,earnings[4001] ,total[4001] ,overlap;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    for( int i=0 ; i<n ; i++ ){ // ??\?????¨????¨?????¨????
      cin >> num[i] >> price[i] >> earnings[i];
      total[i] = price[i] * earnings[i];
    }
 
    for( int i=0 ; i<n ; i++ ){ // ??????????????????
      overlap = num[i]; // ????????????????????????
      for( int j=0 ; j<n ; j++ ){
    if( num[j] == overlap && i != j ){ // ???????????????
      total[i] += total[j];
      num[j] = -1;
      total[j] = 0;
    }
      }
    }
 
    for( int i=0 ; i<n ; i++ ){ // ??????
      if( total[i] >= 1000000 ){
    cout << num[i] << endl;
    flag = 1;
      }
    }
 
    if( flag == 0 ){ // ???????????£??????
      cout << "NA" << endl;
    }
    flag = 0;
  }
}