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 <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cerr << #x << " = " << (x) << "\n"
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

string str[ 3 ];

void input() {
  for ( int i = 0; i < 3; i++ ) {
    cin >> str[ i ];
    if ( str[ i ] == "0" ) {
      break;
    }
  }
}

void solve() {
  if ( str[ 0 ][ 0 ] == str[ 1 ][ 1 ] && str[ 0 ][ 0 ] == str[ 2 ][ 2 ] && str[ 0 ][ 0 ] != '+' ) {
    cout << str[ 0 ][ 0 ] << "\n";
    return;
  }
  for ( int i = 0; i < 3; i++ ) {
    if ( str[ i ][ 0 ] == str[ i ][ 1 ] && str[ i ][ 0 ] == str[ i ][ 2 ] && str[ i ][ 0 ] != '+' ) {
      cout << str[ i ][ 0 ] << "\n";
      return;
    }
    if ( str[ 0 ][ i ] == str[ 1 ][ i ] && str[ 0 ][ i ] == str[ 2 ][ i ] && str[ 0 ][ i ] != '+' ) {
      cout << str[ 0 ][ i ] << "\n";
      return;
    }
  }
  cout << "NA\n";
}

int main() {
  ios::sync_with_stdio( false );
  cin.tie( 0 );
  while ( true ) {
    input();
    if ( str[ 0 ] == "0" ) {
      break;
    }
#ifdef WIN32
    clock_t stime = clock();
#endif
    solve();
#ifdef WIN32
    clock_t etime = clock();
    cerr << "TIME : " << ( double ) ( etime - stime ) / CLOCKS_PER_SEC << "\n";
#endif
  }
return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string s[3];
	bool flg = false;
	cin >> s[0];
	if(s[0] == "0") break;
	cin >> s[1] >> s[2];
	REP(i,3)
	    if(s[i][0] == s[i][1] && s[i][0] == s[i][2]){
		if(s[i][0] == '+') continue;
		cout << s[i][0] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;
	REP(i,3)
	    if(s[0][i] == s[1][i] && s[0][i] == s[2][i]){
		if(s[0][i] == '+') continue;
		cout << s[0][i] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;

	if(s[0][0] == s[1][1] && s[0][0] == s[2][2]){
	    if(s[0][0] != '+'){
		cout << s[0][0] << endl;
		flg = true;
	    }
	}
	if(flg) continue;
	if(s[0][2] == s[1][1] && s[2][0] == s[1][1]){
	    if(s[0][2] != '+'){
		cout << s[0][2] << endl;
		flg = true;
	    }
	}
	if(flg) continue;
	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;
					n = 1;
				}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;
					n = 1;
				}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;
				n = 1;
			}else if(board[1][1] == -1){
				cout << "w" << endl;
				n = 1;
			}
		}
		if((board[1][1] == board[0][2]) && (board[1][1] == board[2][0]) && (n != 1)){
			if(board[1][1] == 1){
				cout << "b" << endl;
				n = 1;
			}else if(board[1][1] == -1){
				cout << "w" << endl;
				n = 1;
			}
		}
		if(n == 0){
			cout << "NA" << endl;
		}
	}
		
		return 0;
}

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

char field[3][4];

char solve(){
	for(int i=0; i<3; i++){
		if(field[i][0] == field[i][1] && field[i][1] == field[i][2])
			return field[i][0];
	}
	for(int k=0; k<3; k++){
		if(field[0][k] == field[1][k] && field[1][k] == field[2][k])
			return field[0][k];
	}
	if(field[0][0] == field[1][1] && field[1][1] == field[2][2])
		return field[0][0];
	if(field[0][2] == field[1][1] && field[1][1] == field[2][0])
		return field[0][2];
	return 'N';
}

int main(){
	while(true){
		for(int i=0; i<3; i++){
			cin >> field[i];
			if(field[0][0] == '0')
				return 0;
		}
		char ans = solve();
		if(ans != 'w' || ans != 'b')
			cout << "NA\n";
		else
			cout << ans << endl;
	}
}

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

char field[3][4];

char solve(){
	for(int i=0; i<3; i++){
		if(field[i][0] == field[i][1] && field[i][1] == field[i][2])
			return field[i][0];
	}
	for(int k=0; k<3; k++){
		if(field[0][k] == field[1][k] && field[1][k] == field[2][k])
			return field[0][k];
	}
	if(field[0][0] == field[1][1] && field[1][1] == field[2][2])
		return field[0][0];
	if(field[0][2] == field[1][1] && field[1][1] == field[2][0])
		return field[0][2];
	return 'N';
}

int main(){
	while(true){
		for(int i=0; i<3; i++){
			cin >> field[i];
			if(field[0][0] == '0')
				return 0;
		}
		char ans = solve();
		if(ans != 'w' || ans != 'n')
			cout << "NA\n";
		else
			cout << ans << endl;
	}
}