#include <cstdio>

int main(){
	char tbl[3][3];
	bool ok, end = false;
	
	for(;;){
		ok = false;
		for(int i = 0; i < 3; i++){
			scanf("%s", &tbl[i]);
			if(tbl[0][0] == '0'){
				end = true;
				break;
			}
		}
		if(end) break;
		if(tbl[0][0] != '+' && tbl[0][0] == tbl[1][1] && tbl[0][0] == tbl[2][2] 
			|| tbl[0][2] == tbl[1][1] && tbl[0][2] == tbl[2][0]){
			printf("%c\n", tbl[1][1]);
			ok = true;
		}else {
			for(int i = 0; i < 3; i++){
				if(tbl[0][0] != '+' && tbl[i][0] == tbl[i][1] && tbl[i][0] == tbl[i][2]){
					printf("%c\n", tbl[i][0]);
					ok = true;
					break;
				}
				if(tbl[0][0] != '+' && tbl[0][i] == tbl[1][i] && tbl[0][i] == tbl[2][i]){
					printf("%c\n", tbl[0][i]);
					ok = true;
					break;
				}
			}
		}
		if(!ok) printf("NA\n");
	}	
	return 0;
}