import std.stdio;
import std.array;
import std.conv;

void main(){
	int n, id;
	ulong value, quantity;
	while (1) {
		readf("%d\n", &n);
		if(n == 0) break;
		bool na = true;
		bool[int] listed;
		int[] printOrder;
		for (int i = 0; i < n; i++) {
			readf("%d %s %s\n", &id, &value, &quantity);
			printOrder ~= id;
			if(value*quantity >= 1000000 &&  !(id in listed)){
				listed[id] = true;
				na = false;
			}
		}
		foreach (i; printOrder) {
			if(i in listed && listed[i]){
				writeln(i);
				listed[i] = false;
			}
		}
		if(na) writeln("NA");
	}
}