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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

char B[3][3];

char check() {
	bool ok = false;
	rep(i,3) {
		ok = true;
		rep(j,3) {
			if(B[i][0] != B[i][j]) {
				ok = false;
				break;
			}
		}
		if(ok) return B[i][0];
	}

	rep(i,3) {
		ok = true;
		rep(j,3) {
			if(B[0][i] != B[j][i]) {
				ok = false;
				break;
			}
		}
		if(ok) return B[0][i];
	}

	ok = true;
	rep(i,3) {
		if(B[1][1] != B[i][i]) {
			ok = false;
			break;
		}
	}
	if(ok) return B[1][1];

	ok = true;
	rep(i,3) {
		if(B[1][1] != B[i][2-i]) {
			ok = false;
			break;
		}
	}
	if(ok) return B[1][1];
	
	return '+';
}

int main() {
	while( 1 ) {
		rep(i,3) {
			rep(j,3) {
				cin >> B[i][j];
				if(i==0 && j==0 && B[i][j] == '0') return 0;
			}
		}

		char a = check();
		if(a != 'b' && a != 'w') printf("NA\n");
		else printf("%c\n", a);
	}
}

C++: // 2011/08/24 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		char brd[3][3];
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				cin >> brd[i][j];
				if(brd[i][j]=='0')	// ¶
					return 0;
			}
		}

		if(brd[0][0]!='+'&&brd[0][0]==brd[0][1]&&brd[0][1]==brd[0][2])
			cout << brd[0][0] << endl;
		else if(brd[1][0]!='+'&&brd[1][0]==brd[1][1]&&brd[1][1]==brd[1][2])
			cout << brd[1][0] << endl;
		else if(brd[2][0]!='+'&&brd[2][0]==brd[2][1]&&brd[2][1]==brd[2][2])
			cout << brd[2][0] << endl;
		else if(brd[0][0]!='+'&&brd[0][0]==brd[1][0]&&brd[1][0]==brd[2][0])
			cout << brd[0][0] << endl;
		else if(brd[0][1]!='+'&&brd[0][1]==brd[1][1]&&brd[1][1]==brd[2][1])
			cout << brd[0][1] << endl;
		else if(brd[0][2]!='+'&&brd[0][2]==brd[1][2]&&brd[1][2]==brd[2][2])
			cout << brd[0][2] << endl;
		else if(brd[0][0]!='+'&&brd[0][0]==brd[1][1]&&brd[1][1]==brd[2][2])
			cout << brd[0][0] << endl;
		else if(brd[0][2]!='+'&&brd[0][2]==brd[1][1]&&brd[1][1]==brd[2][0])
			cout << brd[0][2] << endl;
		else
			cout << "NA" << endl;
	}
}

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

int main() {
    while (true) {
        char field[3][4];
        for (int i = 0; i < 3; i++) {
            cin >> field[i];
        }
        if (field[0][0] == '0') {
            break;
        }
        if (field[1][1] != '+' &&
            ((field[1][1] == field[0][0] && field[1][1] == field[2][2])
             || (field[1][1] == field[0][1] && field[1][1] == field[2][1])
             || (field[1][1] == field[0][2] && field[1][1] == field[2][0])
             || (field[1][1] == field[1][0] && field[1][1] == field[1][2])
            )) {
            cout << field[1][1] << endl;
        } else if (field[0][0] != '+' &&
                   ((field[0][0] == field[0][1] && field[0][0] == field[0][2])
                    || (field[0][0] == field[1][0] && field[0][0] == field[2][0])
                   )) {
            cout << field[0][0] << endl;
        } else if (field[2][2] != '+' &&
                   ((field[2][2] == field[0][2] && field[2][2] == field[1][2])
                    || (field[2][2] == field[2][0] && field[2][2] == field[2][1])
                   )) {
            cout << field[2][2] << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

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

char field[3][3];

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++)
			for(int k=0; k<3; k++){
				cin >> field[i][k];
				if(field[0][0] == '0')
					return 0;
			}
		char ans = solve();
		if(ans == 'N')
			cout << "NA\n";
		else
			cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
string f[3];
int main() {
    while (cin>>f[0]) {
        if (f[0]=="0") break;
        for (int i=1; i<3; i++) cin>>f[i];
        char res='+';
        for (int i=0; i<3; i++) {
            if (f[0][i]==f[1][i]&&f[1][i]==f[2][i]) {
                if (f[0][i]!='+') res=f[0][i];
            }
            if (f[i][0]==f[i][1]&&f[i][1]==f[i][2]) {
                if (f[i][0]!='+') res=f[i][0];
            }
        }
        if (f[0][0]==f[1][1]&&f[1][1]==f[2][2]) {
            if (f[0][0]!='+') res=f[0][0];
        }
        if (f[0][2]==f[1][1]&&f[1][1]==f[2][0]) {
            if (f[0][2]!='+') res=f[0][2];
        }
        if (res=='+') puts("NA");
        else cout<<res<<endl;
    }
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
vector<string> ans;
int rep(char c){
	int sum,k;
	for(int i=0;i<3;i++){
		sum=0;k=0;
		for(int j=0;j<3;j++){
			if(ans[i][j]==c)
				sum++;
			if(ans[j][i]==c)
				k++;
		}
		if(sum==3||k==3)
			return 1;
	}
	if(ans[0][0]==c&&ans[1][1]==c&&ans[2][2]==c)
		return 1;
	if(ans[0][2]==c&&ans[1][1]==c&&ans[2][0]==c)
		return 1;
	return 0;
}
int main(){
	string s;
	while(cin>>s,s[0]!='0'){
		ans.push_back(s);
		for(int i=0;i<2;i++){
			cin>>s;
			ans.push_back(s);
		}
		if(rep('w'))
		cout<<'w'<<endl;
		else if(rep('b'))
		cout<<'b'<<endl;
		else cout<<"NA"<<endl;
		ans.clear();
	}
	return 0;
}