Go: package main

import (
	"bufio"
	"os"
		"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)
const (
	allb = "bbb"
	allw = "www"
)

func main() {
	for scanner.Scan() {
		row1 := scanner.Text()
		if row1 == "0" {
			break
		}
		scanner.Scan()
		row2 := scanner.Text()
		scanner.Scan()
		row3 := scanner.Text()
		x := make([]string, 8)
		x[0] = row1
		x[1] = row2
		x[2] = row3
		for i := 0; i < 3; i++ {
			col := make([]string, 3)
			col[0] = string(row1[i])
			col[1] = string(row2[i])
			col[2] = string(row3[i])
			x[i+3] = strings.Join(col, "")
		}
		tmp := make([]string, 3)
		tmp[0] = string(row1[0])
		tmp[1] = string(row2[1])
		tmp[2] = string(row3[2])
		x[6] = strings.Join(tmp, "")
		tmp[0] = string(row1[2])
		tmp[1] = string(row2[1])
		tmp[2] = string(row3[0])
		x[7] = strings.Join(tmp, "")
		flag := false
		for _, v := range x {
			if string(v) == allb {
				fmt.Println("b")
				flag = true
				break
			} else if string(v) == allw {
				fmt.Println("w")
				flag = true
				break
			}
		}
		if !flag {
			fmt.Println("NA")
		}
	}
}

C++: #include <iostream>

using namespace std;

int checkYoko( char stage[4][4], int i )
{
	if( stage[i][0] == stage[i][1] && stage[i][1] == stage[i][2] ) {
		if( stage[i][0] == 'b' ) return 1;
		else if( stage[i][0] == 'w' ) return 2;
		else return 0;
	}

	return 0;
}

int checkTate( char stage[4][4], int i )
{
	if( stage[0][i] == stage[1][i] && stage[1][i] == stage[2][i] ) {
		if( stage[0][i] == 'b' ) return 1;
		else if( stage[0][i] == 'w' ) return 2;
		else return 0;
	}

	return 0;
}


int main(int argc, char const* argv[])
{
	char stage[4][4];

	while( cin >> stage[0] && stage[0][0] != '0' ){
		for( int i = 1;i < 3;i++ ) cin >> stage[i];

		int i;
		for( i = 0;i < 3;i++ ) {
			int answer = checkYoko( stage, i );
			
			if( answer == 0 ) {
				answer = checkTate( stage, i );
			}

			if( answer == 1 ){
				cout << 'b' << endl;
				break;
			} else if( answer == 2 ){
				cout << 'w' << endl;
				break;
			} else {
				if( stage[0][0] == stage[1][1] && stage[1][1] == stage[2][2] || stage[2][0] == stage[1][1] && stage[1][1] == stage[0][2] ) {
					cout << stage[0][0] << endl;
				}
			}
		}
		if( i == 3 ) cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
int main(){
	std::string m[3], w;
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		w = "NA";
		for(int i=0;i<3;i++){
			char c = m[i][0];
			if(2 * c - m[i][1] - m[i][2] == 0 && c - '+')w = c;
			c = m[0][i];
			if(2 * c - m[1][i] - m[2][i] == 0 && c - '+')w = c;
		}
		if(m[0][0] + m[1][1] - m[2][2] * 2 == 0 && m[0][0] - '+')w = m[0][0];
		if(m[0][2] + m[1][1] - m[2][0] * 2 == 0 && m[0][2] - '+')w = m[0][2];
		
		std::cout << w << '\n';
	}
}

C++: #include <iostream>

using namespace std;

bool judge(char a[3][3], char c)
{
	if(a[0][0] == c && a[0][1] == c && a[0][2] == c ||
	   a[1][0] == c && a[1][1] == c && a[1][2] == c ||
	   a[2][0] == c && a[2][1] == c && a[2][2] == c ||
	   a[0][0] == c && a[1][0] == c && a[2][0] == c ||
	   a[0][1] == c && a[1][1] == c && a[2][1] == c ||
	   a[0][2] == c && a[1][2] == c && a[2][2] == c ||
	   a[0][0] == c && a[1][1] == c && a[2][2] == c ||
	   a[0][2] == c && a[1][1] == c && a[2][0] == c)
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

void solve()
{
	char a[3][3];
	while(cin >> a[0][0], a[0][0] != '0')
	{
		cin >> a[0][1] >> a[0][2];
		for(int i = 1; i < 3; ++i)
		{
			for(int j = 0; j < 3; ++j)
			{
				cin >> a[i][j];
			}
		}
		if(judge(a, 'b'))
		{
			cout << "b" << endl;
		}
		else if(judge(a, 'w'))
		{
			cout << "w" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
#include<string>
using namespace std;

char T[3][3];

string blackwhite() {
	for (int i = 0; i < 3; i++) {
		if (T[i][0] == T[i][1] && T[i][1] == T[i][2]) {
			if (T[i][0] == 'b') { return "b"; }
			if (T[i][0] == 'w') { return "w"; }
		}
	}
	for (int i = 0; i < 3; i++) {
		if (T[0][i] == T[1][i] && T[1][i] == T[2][i]) {
			if (T[0][i] == 'b') { return "b"; }
			if (T[0][i] == 'w') { return "w"; }
		}
	}
	return "NA";
}

int main() {
	while (true) {
		cin >> T[0][0];
		if (T[0][0] == '0') { break; }
		cin >> T[0][1];
		cin >> T[0][2];
		for (int i = 1; i < 3; i++) {
			for (int j = 0; j < 3; j++){
				cin>>T[i][j];
			}
		}
		cout << blackwhite() << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main( void )
{
	while ( 1 )
	{
		vector <string> M(3);
		bool not_found;

		cin >> M[0];
		if ( M[0] == "0" ) break;
		cin >> M[1] >> M[2];

		not_found = true;
		for ( int i = 0; not_found && i < 3; i++ )
		{
			if ( M[i][0] == M[i][1] && M[i][1] == M[i][2] )
			{
				if ( M[i][0] == 'b' || M[i][0] == 'w' )
				{
					cout << M[i][0] << endl;
					not_found = false;
				}
			}
			if ( M[0][i] == M[1][i] && M[1][i] == M[2][i] )
			{
				if ( M[0][i] == 'b' || M[0][i] == 'w' )
				{
					cout << M[0][i] << endl;
					not_found = false;
				}
			}
		}
		if ( not_found && M[0][0] == M[1][1] && M[1][1] == M[2][2] )
		{
			if ( M[0][0] == 'b' || M[0][0] == 'w' )
			{
				cout << M[0][0] << endl;
				not_found = false;
			}
		}
		if ( not_found && M[0][2] == M[1][1] && M[1][1] == M[2][0] )
		{
			if ( M[0][2] == 'b' || M[0][2] == 'w' )
			{
				cout << M[0][2] << endl;
				not_found = false;
			}
		}

		if ( not_found ) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int board[3][3];

int main(){
	char c;
 	while(cin >> c){
		
		if(c == '0'){
			return 0;
		}
		
		//テ、ツスツソテァツ板ィテ」ツδ愿」ツδシテ」ツδ嘉」ツつ?テ」ツ?ァテ・ツ按敕ヲツ慊淌・ツ個?
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				board[i][j] = 0;
			}
		}
		
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(c == 'b'){
					board[i][j] = 1;
				}else if(c == 'w'){
					board[i][j] = -1;
				}
				if((i == 2) && (j == 2)){
				}else{
					cin >> c;
				}
			}
		}
		
		/*
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				cout << board[i][j] << " ";
			}
			cout << endl;
		}*/
		
		int n=0;
		for(int i=0;i<3;i++){
			if((board[i][0] == board[i][1]) && (board[i][0] == board[i][2])){
				if(board[i][0] == 1){
					cout << "b" << endl;
				}else if(board[i][0] == -1){
					cout << "w" << endl;
				}
				n = 1;
			}
		}
		for(int j=0;j<3;j++){
			if((board[0][j] == board[1][j]) && (board[0][j] == board[2][j]) && (n != 1)){
				if(board[0][j] == 1){
					cout << "b" << endl;
				}else if(board[0][j] == -1){
					cout << "w" << endl;
				}
				n = 1;
			}
		}
		if((board[1][1] == board[0][0]) && (board[1][1] == board[2][2]) && (n != 1)){
			if(board[1][1] == 1){
				cout << "b" << endl;
			}else if(board[1][1] == -1){
				cout << "w" << endl;
			}
			n = 1;
		}
		if((board[0][2] == board[1][1]) && (board[0][2] == board[2][0]) && (n != 1)){
			if(board[0][2] == 1){
				cout << "b" << endl;
			}else if(board[1][1] == -1){
				cout << "w" << endl;
			}
			n = 1;
		}
		if(n == 0){
			cout << "NA" << endl;
		}
	}
		
		return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

string m[3];

string solve(){
	for(int i=0 ; i < 3 ; i++ ){
		if( m[i] == "bbb" )
			return "b";
		if( m[i] == "www" )
			return "w";
		if( m[0][i] == 'b' && m[1][i] == 'b' && m[2][i] == 'b' )
			return "b";
		if( m[0][i] == 'w' && m[1][i] == 'w' && m[2][i] == 'w' )
			return "w";
	}
	if( m[0][0] == 'b' && m[1][1] == 'b' && m[2][2] == 'b' )
		return "b";
	if( m[0][0] == 'w' && m[1][1] == 'w' && m[2][2] == 'w' )
		return "w";
	if( m[0][2] == 'b' && m[1][1] == 'b' && m[2][0] == 'b' )
		return "b";
	if( m[0][2] == 'w' && m[1][1] == 'w' && m[2][0] == 'w' )
		return "w";
	return "NA";
}

int main(){
	string s;
	while( cin >> s , s != "0" ){
		m[0] = s;
		cin >> s;
		m[1] = s;
		cin >> s;
		m[2] = s;
		cout << solve() << endl;
	}
}