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 field[3][3];
	while(true){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				cin >> field[i][j];
				if(field[i][j] == '0')
					return 0;
			}
		}
		bool flag = false;
		for(int i=0;i<3;i++){
			if(field[i][1] == field[i][0] && field[i][1] == field[i][2] && field[i][1] != '+'){
				cout << field[i][1] << endl;
				flag = true;
				break;
			}
			if(field[1][i] == field[0][i] && field[1][i] == field[2][i] && field[i][1] != '+'){
				cout << field[1][i] << endl;
				flag = true;
				break;
			}
		}
		if(flag)
			continue;
		if(((field[1][1] == field[0][0] && field[1][1] == field[2][2]) || (field[1][1] == field[2][0] && field[1][1] == field[0][2])) && field[1][1] != '+'){
			cout << field[1][1] << endl;
			continue;
		}
		cout << "NA" << endl;
	}
	return 0;
}

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

bool win_check(char c, char d, char e)
{
  if ( c == 'b' && d == 'b' && e == 'b' )
  {
    cout << 'b' << endl;
    return true;
  }
  else if ( c == 'w' && d == 'w' && e == 'w' )
  {
    cout << 'w' << endl;
    return true;
  }
  return false;
}

int main()
{
  while (true)
  {
    char board[3][3];
    for (int i=0; i<3; i++)
    {
      for (int j=0; j<3; j++)
      {
        cin >> board[i][j];
        if (board[i][j] == '0') return 0;
      }
    }

    bool flag = false;

    for (int i=0; i<3; i++)
    {
      flag = win_check(board[i][0], board[i][1], board[i][2]);
      if ( flag ) break;
    }
    if ( flag ) continue;
    
    for (int j=0; j<3; j++)
    {
      flag = win_check(board[0][j], board[1][j], board[2][j]);
      if ( flag ) break;
    }
    if ( flag ) continue;

    flag = win_check(board[0][0], board[1][1], board[2][2]);
    if ( flag ) continue;
    flag = win_check(board[0][3], board[1][1], board[2][0]);
    if ( flag ) continue;

    cout << "NA" << endl;
  }
}

C++: //AOJ 0183
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s[3];
	char w = 'q';
	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 && s[i][0] != '+') 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 && s[0][i] != '+') 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 && w != '+') {putchar(w);putchar('\n');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 && w != '+') putchar(w),putchar('\n');
fin:
		if(!end || w == '+') puts("NA");
	}
	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 - j] == b[(j+1)%size][size - (j+1)%size]
		 && b[j][size - j] == b[(j+2)%size][size - (j+2)%size] ){
			if (b[j][size - j] != '+'){
				return b[j][size - 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;
}

C++: 
#include<iostream>
using namespace std;
int main()
{
  int i;
  string s[3],ans;
  while(cin>>s[0]>>s[1]>>s[2],s[0]!="0"){
    ans="NA";
    for(i=0;i<3;i++){
      if(s[i][0]!='+' && s[i][0]==s[i][1] && s[i][0]==s[i][2])ans=s[i][0];
      if(s[0][i]!='+' && s[0][i]==s[1][i] && s[0][i]==s[2][i])ans=s[0][i];
    }
    if(s[1][1]!='+' && s[1][1]==s[0][0] && s[1][1]==s[2][2])ans=s[1][1];
    if(s[1][1]!='+' && s[1][1]==s[0][2] && s[1][1]==s[2][0])ans=s[1][1];

    cout<<ans<<endl;
  }
}