#include <stdio.h>

int main(void) {

  int n;

  int id,unit,amount;
  int answer[4000];

  int i,flag;
  int a;


  while(1) {

    scanf("%d",&n);

    if(n==0) break;

    flag=0;
    a=0;

    for(i=0;i<n;i++) {

      scanf("%d %d %d",&id,&unit,&amount);

      if(unit*amount>=1000000) {

	answer[a++]=id;

	flag=1;

      }

    }

    if(flag==0) printf("NA\n");

    else {

      for(i=0;i<a;i++) printf("%d\n",answer[i]);

    }

  }

  return 0;

}