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 <vector>
#include <string>

using namespace std;

int main() {
    vector<string> field(3);
    string s;
    while (cin >> s, s != "0") {
        field[0] = s;
        cin >> field[1];
        cin >> field[2];

        string res = "NA";
        for (int i = 0; i < 3; i++) {
            if (field[i] == "www") {
                res = "w";
                break;
            } else if (field[i] == "bbb") {
                res = "b";
                break;
            }
        }
    
        for (int i = 0; i < 3; i++) {
            if (field[0][i] == field[1][i] && field[1][i] == field[2][i]) {
                if (field[0][i] == 'w') {
                    res = "w";
                    break;
                } else {
                    res = "b";
                    break;
                }
            }
        }
    
        if (field[0][0] == field[1][1] && field[1][1] == field[2][2]) {
            if (field[0][0] == 'w') res = "w";
            else res = "b";
        }
    
        if (field[0][2] == field[1][1] && field[1][1] == field[2][0]) {
            if (field[0][2] == 'w') res = "w";
            else res = "b";
        }
    
        cout << res << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
    char field[3][3];
    while(cin >> field[0], field[0][0] != '0'){
        char win = ' ';
        for(int i=1; i < 3; i++){
            cin >> field[i];
        }

        if(field[0][0] == field[1][1] && field[1][1] == field[2][2] && field[0][0] != '+')win = field[0][0];

        if(field[2][0] == field[1][1] && field[1][1] == field[0][2] && field[2][0] != '+')win = field[2][0];

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

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

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

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	string s[3];
	while(1){
		cin>>s[0];
		if(s[0]=="0") break;
		cin>>s[1]>>s[2];
		string ans="NA";
		rep(i,0,3){
			if(s[i][0]==s[i][1] && s[i][1]==s[i][2]) ans=s[i][0];
			if(s[0][i]==s[1][i] && s[1][i]==s[2][i]) ans=s[0][i];
		}
		if(s[0][0]==s[1][1] && s[1][1]==s[2][2]) ans=s[0][0];
		if(s[0][2]==s[1][1] && s[1][1]==s[2][0]) ans=s[0][2];
		cout<<ans<<endl;
	}
}

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

int main() {
    for(string s1, s2, s3; cin >> s1, s1 != "0"; ) {
        cin >> s2 >> s3;
        string s = s1 + s2 + s3;
        string bit[] = {
            "111000000",
            "000111000",
            "000000111",
            "100100100",
            "010010010",
            "001001001",
            "100010001",
            "001010100"
        };

        int winner = -1;
        for(int i = 0; i < 8; i++) {
            string t;
            for(int j = 0; j < 9; j++) {
                if(bit[i][j] == '1') t.push_back(s[j]);
            }
            if(t[0] == 'w' && t[1] == 'w' && t[2] == 'w') winner = 0;
            if(t[0] == 'b' && t[1] == 'b' && t[2] == 'b') winner = 1;
        }
        if(winner == 0) {
            cout << 'w' << endl;
        }
        else if(winner == 1) {
            cout << 'b' << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	string str;
	while(cin>>str&&str!="0"){
		vector<string> field;
		field.push_back(str);
		for(int i = 0; i < 2; i++){
			cin>>str;
			field.push_back(str);
		}
		bool fin=false;
		// æ±
		for(int i = 0; i < 3; i++){
			bool f=false;
			char ch=field[i][0];
			if(ch!='+'){
				for(int j = 1; j < 3; j++){
					if(ch!=field[i][j]){
						f=true;
						break;
					}
				}
				// sè
				if(!f){
					cout<<ch<<endl;
					fin=true;
					break;
				}
			}
		}
		if(!fin){
			// ½Ä
			for(int i = 0; i < 3; i++){
				bool f=false;
				char ch=field[0][i];
				if(ch!='+'){
					for(int j = 1; j < 3; j++){
						if(ch!=field[j][i]){
							f=true;
							break;
						}
					}
					// sè
					if(!f){
						fin=true;
						cout<<ch<<endl;
						break;
					}
				}
			}
			if(!fin){
				// ÈÈß
				char ch=field[0][0];
				if(ch!='+'&&field[1][1]==ch&&field[2][2]==ch){
					fin=true;
					cout<<ch<<endl;
				}
				else if(field[1][1]!='+'&&field[1][1]==field[2][0]&&field[2][0]==field[0][2]){
					fin=true;
					cout<<field[1][1]<<endl;
				}
				else
					cout<<"NA"<<endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    string a[3];
    char ans;
    while(true){
    	cin >> a[0];
    	if(a[0][0] == '0'){
    		break;
    	}
    	cin >> a[1] >> a[2];
        ans = '0';
        for(int i = 0; i < 3; i++){
            if(a[i][0] == a[i][1] && a[i][1] == a[i][2]){
                if(a[i][0] != '+'){
                    ans = a[i][0];
                }
            }
            if(a[0][i] == a[1][i] && a[1][i] == a[2][i]){
                if(a[0][i] != '+'){
                    ans = a[0][i];
                }
            }
        }
        if(a[0][0] == a[1][1] && a[1][1] == a[2][2]){
            if(a[0][0] != '+'){
                ans = a[0][0];
            }
        }
        if(a[0][2] == a[1][1] && a[1][1] == a[2][0]){
            if(a[0][2] != '+'){
                ans = a[0][2];
            }
        }
        if(ans == '0'){
            printf("NA\n");
        }else{
            printf("%c\n", ans);
        }
    }
    return 0;
}