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>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        vector<string> s(3);
        for(int i=0; i<3; ++i){
            cin >> s[i];
            if(s[i] == "0")
                return 0;
        }

        char win = ' ';
        for(int i=0; i<3; ++i){
            if(s[i][0] != '+' && s[i][0] == s[i][1] && s[i][1] == s[i][2])
                win = s[i][0];
            if(s[0][i] != '+' && s[0][i] == s[1][i] && s[1][i] == s[2][i])
                win = s[0][i];
        }
        if(s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2])
            win = s[0][0];
        if(s[2][0] != '+' && s[2][0] == s[1][1] && s[1][1] == s[0][2])
            win = s[2][0];

        if(win == ' ')
            cout << "NA" << endl;
        else
            cout << win << endl;
    }
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int x[][3]={0,1,2,0,1,2,0,1,2,0,0,0,1,1,1,2,2,2,0,1,2,0,1,2};
int y[][3]={0,0,0,1,1,1,2,2,2,0,1,2,0,1,2,0,1,2,0,1,2,2,1,0};

int main() {
	char ban[3][3];
	while(cin>>ban[0][0],ban[0][0]!='0'){
		cin>>ban[0][1]>>ban[0][2]>>ban[1][0]>>ban[1][1]>>ban[1][2]>>ban[2][0]>>ban[2][1]>>ban[2][2];
		int i;
		bool win=false;
		for(i=0;i<8;i++){
			if(ban[y[i][0]][x[i][0]]=='b'&&ban[y[i][1]][x[i][1]]=='b'&&ban[y[i][2]][x[i][2]]=='b'){cout<<"b"<<endl;win=true;break;}
			if(ban[y[i][0]][x[i][0]]=='w'&&ban[y[i][1]][x[i][1]]=='w'&&ban[y[i][2]][x[i][2]]=='w'){cout<<"w"<<endl;win=true;break;}
		}
		if(win==false)cout<<"NA"<<endl;
	}
	return 0;
}

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

#define rep(i,b) for(int i=0; i<int(b); i++)
using namespace std;

void solve(vector<string> const& s){
    if(s[0][0]==s[0][1] && s[0][1]==s[0][2] && s[0][0] != '+'){
        cout << s[0][0] << endl;
    }
    else if(s[0][0]==s[1][0] && s[1][0]==s[2][0] && s[0][0] != '+'){
        cout << s[0][0] << endl;
    }
    else if(s[0][0]==s[1][1] && s[1][1]==s[2][2] && s[0][0] != '+'){
        cout << s[0][0] << endl;
    }
    else if(s[0][1]==s[1][1] && s[1][1]==s[2][1] && s[0][1] != '+'){
        cout << s[0][1] << endl;
    }
    else if(s[0][2]==s[1][2] && s[1][2]==s[2][2] && s[0][2] != '+'){
        cout << s[0][2] << endl;
    }
    else if(s[0][2]==s[1][1] && s[1][1]==s[2][0] && s[0][2] != '+'){
        cout << s[0][2] << endl;
    }
    else if(s[1][0]==s[1][1] && s[1][1]==s[1][2] && s[1][0] != '+'){
        cout << s[1][0] << endl;
    }
    else if(s[2][0]==s[2][1] && s[2][1]==s[2][2] && s[2][0] != '+'){
        cout << s[2][0] << endl;
    } else {
        cout<< "NA" << endl;
    }
}

int main(){
    while(1){
        vector<string> s(3);
        rep(i,3){
            if(cin >> s[i]) continue;
            return 0;
        }
        solve(s);
    }
}

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

int main() {
    vector<string> bd(3);
    while (cin >> bd[0], bd[0] != "0") {
        for (int i=1; i<3; ++i) cin >> bd[i];
        string res = "NA";
        for (int k=0; k<3; ++k) {
            if (bd[0][k] != '+' && bd[0][k] == bd[1][k] && bd[1][k] == bd[2][k]) res = bd[0][k];
            if (bd[k][0] != '+' && bd[k][0] == bd[k][1] && bd[k][1] == bd[k][2]) res = bd[k][0];
        }
        if (bd[0][0] != '+' && bd[0][0] == bd[1][1] && bd[1][1] == bd[2][2]) res = bd[0][0];
        if (bd[2][0] != '+' && bd[2][0] == bd[1][1] && bd[1][1] == bd[0][2]) res = bd[2][0];
        cout << res << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

char winlose (vector <string> b )
{
	int size = b.size();
	int i,j;

	for (j = 0; j < size; ++j){
		for (i = 0; i < size; ++i){
			if (b[i][j] == b[i][(j+1) % size] 
			 && b[i][j] == b[i][(j+2) % size] ){
				if (b[i][j] != '+'){
					return b[i][j];
				} // end if
			} // end if
			if (b[j][i] == b[(j+1) % size][i] 
			 && b[j][i] == b[(j+2) % size][i] ){
				if (b[j][i] != '+'){
					return b[j][i];
				} // end if
			} // end if
		} // end for
		if (b[j][j] == b[(j+1)%size][(j+1)%size] 
		 && b[j][j] == b[(j+2)%size][(j+2)%size] ){
			if (b[j][j] != '+'){
				return b[j][j];
			} // end if
		} // end if

		if (b[j][size - 1 - j] == b[(j+1) % size][size - 1 - (j+1)%size]
		 && b[j][size - 1 - j] == b[(j+2) % size][size - 1 - (j+2)%size] ){
			if (b[j][size - 1 - j] != '+'){
				return b[j][size - 1 - j];
			} // end if
		} // end if
 	} // end for
		
	return 'd';
}

template<class T> void disp_t (vector <T> t )
{
//	static int count = 0;
	int size = t.size();
	int i,j;
//	++count;

//	cout << "No. " << count << endl;

	for (i = 0; i < size; ++i){
		for (j = 0; j < size; ++j){
			cout << t[i][j];
		} // end for
		cout << endl;
	} // end for
//	cout << endl;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.board", "r", stdin );
	string str = "";
	int i;

	while (1) {
		vector <string> board (3);
		for (i = 0; i < 3; ++i){
			getline (cin, str );
			if (str.empty() || str[0] == '0' ){
				goto end;
			} // end if
			board[i] = str;
		} // end for

		char res = winlose (board );


		switch (res ){
			case 'w': cout << 'w'  << endl; break;
			case 'b': cout << 'b'  << endl; break;
			case 'd':  cout << "NA" << endl; break;
		} // end switch

//		disp_t (board );

	} // end loop
end:		
	return 0;
}