import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range;
void main() {
        int n;
        while ((n=readln.strip.to!int) != 0){
                int[int] t;
                int[] order;
                for(int i=0; i<n; i++){
                        auto l = readln.strip.split(' ').map!(to!int).array;
                        if(!(l[0] in t)){
                                t[l[0]] = 0;
                                order ~= l[0];
                        }
                        t[l[0]] += l[1] * l[2];
                }
                bool flag = true;
                foreach (int key; order)
                {
                        if(t[key] >= 1000000)
                        {
                                writefln("%d", key);
                                flag = false;
                        }
                }
                if(flag) writefln("NA");
        }
}