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<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    string r[3];
    int i;
    while(cin>>r[0]&&r[0]!="0"){
        int ch=0;
        for(i=1;i<3;i++) cin>>r[i];
        for(i=0;i<3;i++){
            if(r[i][0]==r[i][1]
            &&r[i][1]==r[i][2]
            &&r[i][0]!='+'){
                cout<<r[i][0]<<endl;
                ch++;
            }
            if(r[0][i]==r[1][i]
            &&r[1][i]==r[2][i]
            &&r[0][i]!='+'){
                cout<<r[0][i]<<endl;
                ch++;
            }
        }
        if(ch) continue;
        if(r[0][0]==r[1][1]
        &&r[1][1]==r[2][2]
        &&r[0][0]!='+'){
            cout<<r[0][0]<<endl;
            continue;
        }
        if(r[0][2]==r[1][1]
        &&r[1][1]==r[2][0]
        &&r[2][0]!='+'){
            cout<<r[2][0]<<endl;
            continue;
        }
        cout<<"NA"<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int checkYoko( char stage[4][4], int i )
{
	if( stage[i][0] == stage[i][1] && stage[i][1] == stage[i][2] ) {
		if( stage[i][0] == 'b' ) return 1;
		else if( stage[i][0] == 'w' ) return 2;
		else return 0;
	}

	return 0;
}

int checkTate( char stage[4][4], int i )
{
	if( stage[0][i] == stage[1][i] && stage[1][i] == stage[2][i] ) {
		if( stage[0][i] == 'b' ) return 1;
		else if( stage[0][i] == 'w' ) return 2;
		else return 0;
	}

	return 0;
}


int main(int argc, char const* argv[])
{
	char stage[4][4];

	while( cin >> stage[0] && stage[0][0] != '0' ){
		for( int i = 1;i < 3;i++ ) cin >> stage[i];

		int i;
		for( i = 0;i < 3;i++ ) {
			int answer = checkYoko( stage, i );
			
			if( answer == 0 ) {
				answer = checkTate( stage, i );
			}

			if( answer == 1 ){
				cout << 'b' << endl;
				break;
			} else if( answer == 2 ){
				cout << 'w' << endl;
				break;
			} else {
				if( stage[0][0] == stage[1][1] && stage[1][1] == stage[2][2] && stage[0][0] != '+' || stage[2][0] == stage[1][1] && stage[1][1] == stage[0][2] && stage[1][1] != '+' ) {
					cout << stage[0][0] << endl;
					break;
				}
			}
		}
		if( i == 3 ) cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int solve(string s[3]){
  if(s[0][0] == s[0][1] && s[0][1] == s[0][2] && s[0][0] != '+') return (s[0][0] == 'w' ? 0 : 1);
  if(s[1][0] == s[1][1] && s[1][1] == s[1][2] && s[1][0] != '+') return (s[1][0] == 'w' ? 0 : 1);
  if(s[2][0] == s[2][1] && s[2][1] == s[2][2] && s[2][0] != '+') return (s[2][0] == 'w' ? 0 : 1);

  if(s[0][0] == s[1][0] && s[1][0] == s[2][0] && s[0][0] != '+') return (s[0][0] == 'w' ? 0 : 1);
  if(s[0][1] == s[1][1] && s[1][1] == s[2][1] && s[0][1] != '+') return (s[0][1] == 'w' ? 0 : 1);
  if(s[0][2] == s[1][2] && s[1][2] == s[2][2] && s[0][2] != '+') return (s[0][2] == 'w' ? 0 : 1);

  if(s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[0][0] != '+') return (s[0][0] == 'w' ? 0 : 1);
  if(s[0][2] == s[1][1] && s[1][1] == s[2][0] && s[0][2] != '+') return (s[0][0] == 'w' ? 0 : 1);

  return -1;
}
 
int main() {
  string s[3];
  while(cin >>s[0] && s[0] != "0"){
    cin >>s[1] >>s[2];
    int ans = solve(s);
    if(ans == 0) cout <<"w" <<endl;
    else if(ans == 1) cout <<"b" <<endl;
    else cout <<"NA" <<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	while (true) {
		string maps[3];
		cin >> maps[0];
		if (maps[0][0] == '0') break;
		cin >> maps[1] >> maps[2];
		
		int ans = -1;
		REP(i, 3) {
			if (maps[i][0] == maps[i][1] && maps[i][1] == maps[i][2] && maps[i][0] != '+') ans = maps[i][0] == 'b';
			if (maps[0][i] == maps[1][i] && maps[1][i] == maps[2][i] && maps[0][i] != '+') ans = maps[0][i] == 'b';
		}
		if (maps[0][0] == maps[1][1] && maps[1][1] == maps[2][2] && maps[1][1] != '+') ans = maps[1][1] == 'b';
		if (maps[2][0] == maps[1][1] && maps[1][1] == maps[0][2] && maps[1][1] != '+') ans = maps[1][1] == 'b';
		
		if (ans == -1) puts("NA");
		else if (ans == 1) puts("b");
		else puts("w");
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	vector<string> s(3, "");
	string ans;
	while (1) {
		cin >> s[0] >> s[1] >> s[2];
		if (cin.eof())break;
		ans = "NA";
		for (int i = 0; i < 3; i++) {
			if ((s[i][0] != '+'&&s[i][0] == s[i][1] && s[i][1] == s[i][2])) {
				ans = s[i][0];
				break;
			}
			if ((s[0][i] != '+'&&s[0][i] == s[1][i] && s[1][i] == s[2][i])) {
				ans = s[0][i];
				break;
			}
		}
		if (s[1][1] != '+') {
			if ((s[1][1] == s[0][2] && s[1][1] == s[2][0]) || (s[1][1] == s[0][0] && s[1][1] == s[2][2])) {
				ans = s[1][1];
			}
		}
		cout << ans << endl;
	}
}