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 <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

bool solve(char c1,char c2, char c3){
  if(c1 == c2 && c2 == c3 && c1 != '+'){
    cout << c1 << endl;
    return true;
  }
  return false;
}
int a[] = {0,3,6};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,s2;
  while(1){
    bool f = false,f2 = false;
    s.clear();
    rep(i,3){
      cin >> s2;
      if(s2 == "0"){
        f2 = true;
        break;
      }
      s += s2;
    }
    if(f2) break;
    rep(i,3){
      if(solve(s[a[i]],s[a[i]+1],s[a[i]+2])){
        f = true;
        break;
      }
    }
    if(!f){
      rep(i,3){
        if(solve(s[i],s[i+3],s[i + 6])){
          f = true;
          break;
        }
      }
    }
    if(!f){
      if(!solve(s[0],s[4],s[8])){
        if(solve(s[2],s[4],s[6])){
          f = true;
        }
      }
      else f = true;
    }
    if(!f){
      cout << "NA"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef pair<string, int> P;
/** Problem0183 : Black-and-White **/
int main()
{
	string board;
	while (cin>>board, board!="0") {
		string s; cin>>s;
		board+=s;
		cin >>s; board+=s;
		for (int i=0; i<3; i++) {
			if (board[i*3] != '+' && board[i*3] == board[i*3+1] && board[i*3] == board[i*3+2]) {
				cout << board[i*3] << endl;
				goto end;
			}
			else if (board[i] != '+' && board[i] == board[i+3] && board[i] == board[i+6]) {
				cout << board[i] << endl;
				goto end;
			}
		}
		
		if (board[0] != '+' && board[0] == board[4] && board[0] == board[8])
			cout << board[0] << endl;
		else if (board[2] != '+' && board[2] == board[4] && board[2] == board[6])
			cout << board[2] << endl;
		else
			cout << "NA" << endl;
		
	end: ;
	}
	return 0;
}

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

int main() {
	char b[5][5];

	while (cin >> b[0] ) {
		if (b[0][0] == '0')break;
		cin >> b[1] >> b[2];
		string x;
		if (b[0][0] == b[0][1] && b[0][1] == b[0][2] && b[0][0] != '+') { x = b[0][0]; }
		else if (b[1][0] == b[1][1] && b[1][1] == b[1][2] && b[1][0] != '+') { x = b[1][0]; }
		else if (b[2][0] == b[2][1] && b[2][1] == b[2][2] && b[2][0] != '+') { x = b[2][0]; }
		else if (b[0][0] == b[1][0] && b[1][0] == b[2][0] && b[0][0] != '+') { x = b[0][0]; }
		else if (b[0][1] == b[1][1] && b[1][1] == b[2][1] && b[0][1] != '+') { x = b[0][1]; }
		else if (b[0][2] == b[1][2] && b[1][2] == b[2][2] && b[0][2] != '+') { x = b[0][2]; }
		else if (b[0][0] == b[1][1] && b[1][1] == b[2][2] && b[0][0] != '+') { x = b[0][0]; }
		else if (b[0][2] == b[1][1] && b[1][1] == b[2][0] && b[0][2] != '+') { x = b[0][2]; }
		else x = "NA";
		cout << x << 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][i] << 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;
			}
		}
	}
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	string s;
	while(cin >> s)
	{
		if(s == "0") break;
	
		vector<string> v;
		v.push_back(s);

		rep(i,2)
		{
			string temp;
			cin >> temp;
			v.push_back(temp);
		}

		bool flag = true;

		rep(i,3)
		{
			if(v[i][0] == v[i][1] && v[i][1] == v[i][2])
			{
				if(v[i][0] == 'b' || v[i][0] == 'w')
				{
					cout << v[i][0] << endl;
					flag = false;
					break;
				}
			}

			if(v[0][i] == v[1][i] && v[1][i] == v[2][i])
			{
				if(v[0][i] == 'b' || v[0][i] == 'w')
				{
					cout << v[0][i] << endl;
					flag = false;
					break;
				}
			}
		}

		if(flag)
		{
			if(v[0][0] == v[1][1] && v[1][1] == v[2][2])
			{
				if(v[0][0] == 'b' || v[0][0] == 'w')
				{
					cout << v[0][0] << endl;
					flag = false;
				}
			}

			else if(v[2][0] == v[1][1] && v[1][1] == v[0][2])
			{
				if(v[2][0] == 'b' || v[2][0] == 'w')
				{
					cout << v[2][0] << endl;
					flag = false;
				}
			}
		}

		if(flag) cout << "NA" << endl;
	}
	return 0;
}