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 main(void){
    for(;;){
    char a[3][3];
    int f=0,z=0;
    for (int i=0;i<3;i++){
        cin>>a[i];
        if(a[i][0]=='0'){
            z++;
            break;
        }
        }
        if(z!=0)break;

    for(int i=0;i<1;i++){
        for(int j=0;j<3;j++){
            if(a[i][j]!='+'){
                if(a[0][j]==a[1][j]&&a[1][j]==a[2][j]){
                    cout<<a[0][j]<<endl;
                    f++;
                    goto c;
                }
            }
        }
    }
    for(int j=0;j<1;j++){
        for(int i=0;i<3;i++){
            if(a[i][j]!='+'){
                if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
                    cout<<a[i][0]<<endl;
                    f++;
                    goto c;
                }
            }
        }
    }
    if(a[0][0]!='+'){
        if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]){
            cout<<a[0][0]<<endl;
            f++;
            goto c;
        }

    }
    if(a[0][2]!='+'){
        if(a[0][2]==a[1][1]&&a[1][1]==a[2][0]){
            cout<<a[0][0]<<endl;
            f++;
            goto c;
        }
    }

    if(f==0)cout<<"NA"<<endl;
    c:;


    }
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	vector<string> s(3, "");
	string ans;
	while (1) {
		cin >> s[0] >> s[1] >> s[2];
		if (cin.eof())break;
		ans = "NA";
		for (int i = 0; i < 3; i++) {
			if ((s[i][0] != '+'&&s[i][0] == s[i][1] && s[i][1] == s[i][2])) {
				ans = s[i][0];
				break;
			}
			if ((s[0][i] != '+'&&s[0][i] == s[1][i] && s[1][i] == s[0][i])) {
				ans = s[0][i];
				break;
			}
		}
		if (s[1][1] != '+') {
			if ((s[1][1] == s[0][2] && s[1][1] == s[2][0]) || (s[1][1] == s[0][0] && s[1][1] == s[2][2])) {
				ans = s[1][1];
			}
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
char same(char c[3][3]) {
	rep(i,3) {
		if(c[i][0] == c[i][1] && c[i][1] == c[i][2]) return c[i][0];
	}
	rep(i,3) {
		if(c[0][i] == c[1][i] && c[1][i] == c[2][i]) return c[0][i];
	}
	if(c[0][0] == c[1][1] && c[1][1] == c[2][2]) return c[0][0];
	if(c[2][0] == c[1][1] && c[1][1] == c[0][2]) return c[2][0];
	return '+';
}
int main(){
	char b[3][3];
	string s;
	while(cin >> s, s != "0") {
		rep(i,3) {
			b[0][i] = s[i];
		}
		rep2(i,1,3) {
			cin >> s;
			rep(j,3) {
				b[i][j]= s[j];
			}
		}
		if(same(b) == '+') cout << "NA" << endl;
		else cout << same(b) << endl;
	}
	return 0;
}

C++: //AOJ 0183
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s[3];
	char w;
	while (1) {
		for (auto& i : s) {
			cin>>i;
			if(i == "0") return 0;
		}
		bool end = false;
		for (int i = 0; i < 3; i++) {
			char c = s[i][0];
			bool flag = true;
			for (int j = 0; j < 3; j++)
				if(s[i][j] != c) {flag = false;break;}
			if(flag) putchar(c),putchar('\n'),end = true;
		}
		if(end) goto fin;
		for (int i = 0; i < 3; i++) {
			char c = s[0][i];
			bool flag = true;
			for (int j = 0; j < 3; j++)
				if(s[j][i] != c) {flag = false;break;}
			if(flag) putchar(c),putchar('\n'),end = true;
		}
		if(end) goto fin;
		w = s[0][0];
		end = true;
		for (int i = 0; i < 3; i++)
			if(s[i][i] != w){end = false;break;}
		if(end) putchar(w),putchar('\n');
		if(end) goto fin;
		w = s[0][2];
		end = true;
		for (int i = 0; i < 3; i++) {
			if(s[i][2-i] != w) {end = false;break;}
		}
		if(end) putchar(w),putchar('\n');
fin:
		if(!end) puts("NA");
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
bool b00l;
void check(char c) {
	if (c == 'b') { cout << "b\n"; b00l = true; }
	else if (c == 'w') { cout << "w\n"; b00l = true; }
	return;
}
int main() {
	string a, b, c;
	while (cin >> a) {
		if (a.size() == 1)return 0;
		cin >> b >> c;
		b00l = false;
		if (a[0] == a[1] && a[1] == a[2])check(a[0]);
		if (b[0] == b[1] && b[1] == b[2])check(b[0]);
		if (c[0] == c[1] && c[1] == c[2])check(c[0]);
		if (a[0] == b[0] && b[0] == c[0])check(a[0]);
		if (a[1] == b[1] && b[1] == c[1])check(a[1]);
		if (a[2] == b[2] && b[2] == c[2])check(a[2]);
		if (a[0] == b[1] && b[1] == c[2])check(a[0]);
		if (c[0] == b[1] && b[1] == a[2])check(a[2]);
		if (!b00l)cout << "NA\n";
	}
}

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

char mat[3][3];

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

    return '?';
}


int main(){
    while(1){
        cin >> mat[0][0];
        if(mat[0][0] == '0')    break;
        cin >> mat[0][1] >> mat[0][2];
        for(int i = 1; i < 3; i++){
            for(int j = 0; j < 3; j++){
                cin >> mat[i][j];
            }
        }
        char res = judge();
        if(res == '?')  cout << "NA" << endl;
        else            cout << res << endl;
    }
    return 0;
}