#include <iostream>
#include <string>
#include <vector>
using namespace std;

string solve( vector< string >& map )
{
	char row, col, rd, ld, comp;
	rd = map[ 0 ][ 0 ];
	ld = map[ 0 ][ 2 ];
	for( int i = 0; i < 3; ++i ){
		row = map[ 0 ][ i ];
		col = map[ i ][ 0 ];
		for( int j = 0; j < 3; ++j ){
			if( row != map[ j ][ i ] ){
				row = 0;
			}
			if( col != map[ i ][ j ] ){
				col = 0;
			}
		}
		comp = row | col;
		if( comp && comp != '+' ){
			return string( 1, row | col );
		}
		if( rd != map[ i ][ i ] ){
			rd = 0;
		}
		if( ld != map[ i ][ 2 - i ] ){
			ld = 0;
		}
	}

	comp = rd | ld;

	return ( comp && comp != '+' ) ? string( 1, comp ) : "NA";
}

int main()
{
	string s;
	while( cin >> s && s != "0" ){
		vector< string > map;
		map.push_back( s );
		for( int i = 0; i < 2; ++i ){
			cin >> s;
			map.push_back( s );
		}
		cout << solve( map ) << endl;
	}

	return 0;
}