#include<iostream>
using namespace std;

int main(){

	int cnt_b, cnt_w;
	char c[3][3];
	
	while(cin >> c[0][0]){
		if(c[0][0] == '0') break;
		
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(i != 0 || j != 0){
					cin >> c[i][j];
				}
			}
		}
		
	
		if(c[0][0] == c[1][1] && c[1][1] == c[2][2] ||
			 c[2][0] == c[1][1] && c[1][1] == c[0][2]){
			if(c[1][1] != '+') cout << c[1][1] << endl;
			else cout << "NA" << endl;
		}
		else {
			for(int i=0; i<3; i++){
				if(c[i][0] == c[i][1] && c[i][1] == c[i][2] || 
					 c[0][i] == c[1][i] && c[1][i] == c[2][i]){
					if(c[i][i] != '+'){
						cout << c[i][i] << endl;
						break;
					}
					else {
						cout << "NA" << endl;
						break;
					}
				}
				if(i == 2) cout << "NA" << endl;
			}
		}
		
	}

	return 0;

}