import std.stdio;
import std.conv;

void main(){
	int n, id, value, quantity;
	bool na;
	while (1) {
		readf("%d\n", &n);
		if(n == 0) break;
		na = true;
		for (int i = 0; i < n; i++) {
			readf("%d %d %d\n", &id, &value, &quantity);
			auto digit = to!string(value).length + to!string(quantity).length;
			if(digit >= 8 || value*quantity >= 1000000){
				writeln(id);
				na = false;
			}
		}
		if(na) writeln("NA");
	}
}