/*Kim Jong Il*/
#include<iostream>
#include<cstdio>
#define N1 4000
using namespace std;

int main(){
  int n,id[N1],array[N1][N1],i,j,count;
  
  while(1){
    count = 0;
    cin >> n;
    if(n == 0)break;
    
    for(i=0;i<n;i++){
      cin >> id[i];
      for(j=0;j<2;j++){
	cin >> array[i][j];
      }
    }
    for(i=0;i<n;i++){
      if(array[i][0] * array[i][1] >= 1000000){
	cout << id[i] << endl;
	count++;
      }
    }
    if(count == 0)cout << "NA" << endl;   
  }
}