#include<cstdio>
using namespace std;
int main(){
    int n;

    while(scanf("%d",&n),n){

        int mem[4500] = {0};
        int a,x,y;
        int xx = 0;

        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&a,&x,&y);
            mem[a] += x*y;
            if(xx < a)xx = a;
        }
        bool flg = 0;
        for(int i = 1;i <= xx; i++){
            if(mem[i] >= 1000000){
                printf("%d\n",i);
                flg = 1;
            }
        }
        if(flg == 0)printf("NA\n");
    }
    return 0;
}