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(){
	char b[3][3];
	int x,y;
	int check;
	int boolean = 1;

	while(boolean){
		x = 0;
		y = 0;
		check = 1;
		for(int i = 0; i < 3; i++){
			cin >> b[i];
			if(b[0][0] == '0'){
				 boolean = 0;
				 check = 0;
				 break;
			}
		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'b' && b[i][1] == 'b' && b[i][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'b' && b[1][i] == 'b' && b[2][i] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'b' && b[1][1] == 'b' && b[2][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[2][0] == 'b' && b[1][1] == 'b' && b[3][0] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}

		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'w' && b[i][1] == 'w' && b[i][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'w' && b[1][i] == 'w' && b[2][i] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'w' && b[1][1] == 'w' && b[2][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[2][0] == 'b' && b[1][1] == 'b' && b[3][0] == 'b'){
		cout << 'w' << endl;
		check = 0; break;
			}

		}
		if(check) cout << "NA" << endl;
	}
}

C++: #include<iostream>
main(){std::string s[3],A;for(int i,t;std::cin>>s[0]>>s[1]>>s[2],s[0]!="0";std::cout<<A<<"\n"){A="+";for(i=3;i-->0;){t=s[i][0];if(t==s[i][1]&t==s[i][2])A=t;t=s[0][i];if(t==s[1][i]&t==s[2][i])A=t;}t=s[1][1];if(t==s[0][0]&t==s[2][2]||t==s[0][2]&t==s[2][0])A=t;if(A=="+")A="NA";}}

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);
		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>
using namespace std;

char board[8][8] = {{'+'}};
string ans = "NA";

void winp(char c, int x, int y){
    if (board[x][y] == c && board[x+1][y] == c && board[x+2][y] == c) ans = c;
    if (board[x][y] == c && board[x+1][y+1] == c && board[x+2][y+2] == c) ans = c;
    if (board[x][y] == c && board[x][y+1] == c && board[x+2][y+2] == c) ans = c;
}

int main(){
    while (1){
	bool end = false;
	for (int i = 0; i < 3 && !end; i++){
	    for (int j = 0; j < 3 && !end; j++){
		cin >> board[i][j];
		if (board[0][0] == '0') end = true;
	    }
	}
	if (end) break;
	ans = "NA";
	for (int i = 0; i < 3; i++)
	    for (int j = 0; j < 3; j++)
		if (board[i][j] == 'b') winp('b', i, j);
		else if (board[i][j] == 'w') winp('w', i, j);
	
	cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;

char a[3][3];
int main() {
	while (cin >> a[0][0], a[0][0] != 48) {
		rep(i, 3)rep(j, 3)if (i || j)cin >> a[i][j];
		rep(i, 3) {
			if (a[i][0] == a[i][1] && a[i][1] == a[i][2] && a[i][0] != '+') {
				cout << a[i][0] << endl;
				goto p;
			}
			if (a[0][i] == a[1][i] && a[1][i] == a[2][i] && a[0][i] != '+') {
				cout << a[0][i] << endl;
				goto p;
			}
		}
		if (a[0][0] == a[1][1] && a[1][1] == a[2][2] && a[0][0] != '+') {
			cout << a[0][0] << endl;
			goto p;
		}
		if (a[0][2] == a[1][1] && a[1][1] == a[2][0] && a[0][2] != '+') {
			cout << a[0][2] << endl;
			goto p;
		}
		puts("NA");
	p:;
	}
}

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++;
            }
        }
    }
    for(int j=0;j<1;j++){
        for(int i=0;i<3;i++){
            if(a[i][j]!='+'){
                if(a[0][j]==a[1][j]&&a[1][j]==a[2][j])cout<<a[0][j]<<endl,f++;
            }
        }
    }
    if(a[0][0]!='+'){
        if(a[0][0]==a[1][1]&&a[1][1]==a[2][2])cout<<a[0][0]<<endl,f++;
    }
    if(a[0][2]!='+'){
        if(a[0][2]==a[1][1]&&a[1][1]==a[2][0])cout<<a[0][0]<<endl,f++;
    }

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


    }
    return 0;
}

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

bool judge( char a, char b, char c )
{
    if( a == b && b == c && a != '+' )
        return true;
    return false;
}

int main()
{
    char c[3][3];

    while( cin >> c[0][0] )
    {
        if( c[0][0] == '0' )
            break;
        
        cin >> c[0][1] >> c[0][2];
        for( int i = 1; i < 3; i++ )
            for( int j = 0; j < 3; j++ )
                cin >> c[i][j];

        bool na = true, one = true;
        for( int i = 0; i < 3; i++ )
            if( judge( c[i][0], c[i][1], c[i][2] ) || judge( c[0][i], c[1][i], c[2][i] ) )
            {
                cout << c[i][i] << endl;
                na = false;
                one = false;
                break;
            }

        if( judge( c[0][0], c[1][1], c[2][2] ) || judge( c[0][2], c[1][1], c[2][0] ) && one )
        {
            cout << c[1][1] << endl;
            na = false;
        }
        if( na )
            cout << "NA" << endl;
    }
    return 0;
}