import std.stdio, std.algorithm, std.conv, std.string;

void main(){
    while(true){
        ulong[int] sales;
        int[] order;
        int data=readln.chomp.to!int;
        if(data==0)break;
        foreach(_;0..data){
            auto inp=readln.split.map!(to!int);
            int id=inp[0],sale=inp[1],num=inp[2];
            if(id in sales){
                sales[id]+=sale*num;
            }else{
                order~=id;
                sales[id]=sale*num;
            }
        }
        bool na=true;
        foreach(id;order){
            if(sales[id]>=1_000_000){
                id.writeln;
                na=false;
            }
        }
        na&&"NA".writeln;
    }
}