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 <string>

using namespace std;

char solve(char board[9]) {
	//テァツクツヲ
	for (int i = 0; i < 3; i++)
		if (board[i] != '+' && board[i] == board[i + 3] && board[i] == board[i + 3 * 2]) 
			return board[i];

	//テヲツィツェ
	for (int i = 0; i < 9; i += 3)
		if (board[i] != '+' && board[i] == board[i + 1] && board[i] == board[i + 2])
			return board[i];

	//テヲツ鳴愿」ツつ?
	if (board[0] != '+' && board[0] == board[3 + 1] && board[0] == board[3 * 2 + 2])
		return board[0];
	if (board[2] != '+' && board[2] == board[3 + 1] && board[2] == board[3 * 2])
		return board[0];

	return 0;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while (1) {
		char board[9];
		cin >> board[0];
		if (board[0] == '0') break;
		for (int i = 1; i < 9; i++)
			cin >> board[i];
		char c;
		if ((c = solve(board)))
			cout << c << endl;
		else
			cout << "NA" << endl;
	}
}

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

using namespace std;


int main() {

  string buf;

  int board[3][3];


  while(getline(cin,buf)) {

    if(buf[0]=='0') break;

    for(int i=0;i<3;i++) {

      switch(buf[i]) {
	  
      case '+':
	board[0][i]=0;
	break;

      case 'b':
	board[0][i]=1;
	break;

      case 'w':
	board[0][i]=2;
	break;

      }

    }

    for(int i=1;i<3;i++) {

      getline(cin,buf);

      for(int j=0;j<3;j++) {

	switch(buf[j]) {
	  
	case '+':
	  board[i][j]=0;
	  break;

	case 'b':
	  board[i][j]=1;
	  break;

	case 'w':
	  board[i][j]=2;
	  break;

	}

      }

    }
    /*
    for(int i=0;i<3;i++) {

      for(int j=0;j<3;j++) cout << board[i][j];

      cout << endl;

    }
    */
    if((board[0][0]==1 && board[0][1]==1 && board[0][2]==1) || (board[1][0]==1 && board[1][1]==1 && board[1][2]==1) || (board[2][0]==1 && board[2][1]==1 && board[2][2]==1) || (board[0][0]==1 && board[1][0]==1 && board[2][0]==1) || (board[0][1]==1 && board[1][1]==1 && board[2][1]==1) || (board[0][2]==1 && board[1][2]==1 && board[2][2]==1) || (board[0][0]==1 && board[1][1]==1 && board[2][2]==1)) cout << "b" << endl;

    else if((board[0][0]==2 && board[0][1]==2 && board[0][2]==2) || (board[1][0]==2 && board[1][1]==2 && board[1][2]==2) || (board[2][0]==2 && board[2][1]==2 && board[2][2]==2) || (board[0][0]==2 && board[1][0]==2 && board[2][0]==2) || (board[0][1]==2 && board[1][1]==2 && board[2][1]==2) || (board[0][2]==2 && board[1][2]==2 && board[2][2]==2) || (board[0][0]==2 && board[1][1]==2 && board[2][2]==2)) cout << "w" << endl;

    else cout << "NA" << endl;

  }

  return 0;

}

C++: #include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  int b,w;
  
  string str[3];
  int cnt = 0 ;
  while(getline(cin,str[cnt]),str[cnt]!="0"){
    if(cnt==2){
      if(str[0][0] == str[0][1] && str[0][1] == str[0][2])cout<<str[0][1];
      else if(str[1][0] == str[1][1] && str[1][1] == str[1][2])cout<<str[1][1];
      else if(str[2][0] == str[2][1] && str[2][1] == str[2][2])cout<<str[2][1];


      else if(str[0][0] == str[1][0] && str[1][0] == str[2][0])cout<<str[0][0];
      else if(str[0][1] == str[1][1] && str[1][1] == str[2][1])cout<<str[0][1];
      else if(str[0][2] == str[1][2] && str[1][2] == str[2][2])cout<<str[0][2];
      
      else cout<<"NA";
      cout<<endl;
      b = w = 0;
      cnt = -1;
    }
    cnt++;
  }
  return 0;
}

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

int main()
{
  string map[3];
  for(;cin>>map[0],map[0]!="0";)
    {
      cin>>map[1];
      cin>>map[2];
      string ans="NA";
      for(int i=0;i<3;i++)
	{
	  if(map[i][0]!='+' && map[i][0]==map[i][1]&&map[i][1]==map[i][2])
	    ans=map[i][0];
	  if(map[0][i]!='+' && map[0][i]==map[1][i]&&map[1][i]==map[2][i])
	    ans=map[0][i];
	}
      if(map[0][0]!='+' && map[0][0]==map[1][1]&&map[1][1]==map[2][2])
	ans=map[0][0];
      if(map[0][2]!='+' &&map[0][2]==map[1][1]&&map[1][1]==map[2][0])
	ans=map[0][2];
      cout<<ans<<endl;
    }
}

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

char t[4][4];

char judge(void){
	for(int i=0;i<3;i++){
		int j;
		for(j=1;j<3;j++){
			if(t[i][j-1] != t[i][j]) break;
		}
		if(j == 3 && t[i][0] != '+'){
			return t[i][0];
		}
	}
	for(int j=0;j<3;j++){
		int i;
		for(i=1;i<3;i++){
			if(t[i-1][j] != t[i][j]) break;
		}
		if(i == 3 && t[0][j] != '+'){
			return t[0][j];
		}
	}

	if(t[0][0] == t[1][1] && t[1][1] == t[2][2] && t[0][0]!='+'){
		return t[0][0];
	}
	if(t[0][2] == t[1][1] && t[1][1] == t[2][0] && t[0][2]!='+'){
		return t[0][2];
	}
	return '+';
}

int main(void){
	while(1){
		for(int i=0;i<3;i++){
			cin>>t[i];
			if(t[0][0] == '0') return 0;
		}
		char tmp = judge();
		if(tmp == '+')
			cout<<"NA\n";
		else
			cout<<tmp<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **)
{
	int f;
	char a[3][4];
	
	while(scanf("%s", a[0])!=EOF){
		if(a[0][0] == '0'){
			break;
		}
		f = 0;
		scanf("%s", a[1]);
		scanf("%s", a[2]);
		for(int i = 0; i < 3; i++){
			if(a[0][i] == a[1][i] && a[0][i] == a[2][i] && (a[0][i] == 'w' || a[0][i] == 'b')){
				cout << a[0][0] << endl;
				f = 1;
				break;
			}
		}
		if(f == 0){
			if(a[0][0] == a[1][1] && a[0][0] == a[2][2] && (a[0][0] == 'w' || a[0][0] == 'b')){
				cout << a[0][0] << endl;
			} else if(a[0][2] == a[1][1] && a[0][2] == a[2][0] && (a[1][1] == 'w' || a[1][1] == 'b')){
				cout << a[1][1] << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
}