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;
int main() {
	string s1, s2, s3;
	while (cin >> s1){
		if (s1 == "0")return 0;
		cin >> s2 >> s3;
		if (s1[0] != '+') {
			if (s1[0] == s1[1] && s1[0] == s1[2]) { cout << s1[0]; goto heaven; }
			else if (s1[0] == s2[1] && s1[0] == s3[2]) { cout << s1[0]; goto heaven; }
			else if (s1[0] == s2[0] && s1[0] == s3[0]) { cout << s1[0]; goto heaven; }
		}
		if (s1[1] != '+') {
			if (s1[1] == s2[1] && s1[1] == s3[1]) { cout << s1[1]; goto heaven; }
		}
		if (s1[2] != '+') {
			if (s1[2] == s2[1] && s1[2] == s3[0]) { cout << s1[2]; goto heaven; }
			else if (s1[2] == s2[2] && s1[2] == s3[2]) { cout << s1[2]; goto heaven; }
		}
		if (s2[0] != '+') {
			if (s2[0] == s2[1] && s2[0] == s2[2]) { cout << s2[0]; goto heaven; }
		}
		if (s3[0] != '+') {
			if (s3[0] == s3[1] && s3[0] == s3[2]) { cout << s3[0]; goto heaven; }
		}
		cout << "NA";
	heaven:cout << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string str1, str2, str3;
  while (cin >> str1, str1 != "0"){
    bool b, w;
    b = w = false;
    cin >> str2 >> str3;
 
    if (str1[0] == str1[1] && str1[1] == str1[2]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str2[0] == str2[1] && str2[1] == str2[2]){
      if (str2[0] == 'b') b = true;
      if (str2[0] == 'w') w = true;
    }
    else if (str3[0] == str3[1] && str3[1] == str3[2]){
      if (str3[0] == 'b') b = true;
      if (str3[0] == 'w') w = true;
    }
    else if (str1[0] == str2[0] && str2[0] == str3[0]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str1[1] == str2[1] && str2[1] == str3[1]){
      if (str1[1] == 'b') b = true;
      if (str1[1] == 'w') w = true;
    }
    else if (str1[2] == str2[2] && str2[2] == str3[2]){
      if (str1[2] == 'b') b = true;
      if (str1[2] == 'w') w = true;
    }
    else if (str1[0] == str2[1] && str2[1] == str3[2]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str1[2] == str2[1] && str2[1] == str3[0]){
      if (str1[2] == 'b') b = true;
      if (str1[2] == 'w') w = true;
    }
 
    if (b)  cout << 'b';
    if (w) cout << 'w';
    if (!b && !w)cout << "NA";
    cout << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
  string b[3];
  while (cin >> b[0], b[0] != "0"){
    int f = 0;
    cin >> b[1] >> b[2];
    for (int i = 0; i < 3; i++){
      if (b[i] == "bbb"){
        f = 1;
        break;
      }
      else if (b[i] == "www"){
        f = 2;
        break;
      }
      else {
        string str = "";
        str += b[0][i];
        str += b[1][i];
        str += b[2][i];
        if (str == "bbb"){
          f = 1;
          break;
        }
        if (str == "www"){
          f = 2;
          break;
        }
      }
    }
    if (f == 0){
      string str = "";
      str += b[0][0];
      str += b[1][1];
      str += b[2][2];
      if (str == "bbb") f = 1;
      else if (str == "www") f = 2;
      str = "";
      str += b[0][2];
      str += b[1][1];
      str += b[2][0];
      if (str == "bbb") f = 1;
      else if (str == "www") f = 2;
    }

    if (f == 0) cout << "NA\n";
    else if (f == 1) cout << "b\n";
    else if (f == 2) cout << "w\n";
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cerr << #x << " = " << (x) << "\n"
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

string str[ 3 ];

void input() {
  for ( int i = 0; i < 3; i++ ) {
    cin >> str[ i ];
    if ( str[ i ] == "0" ) {
      break;
    }
  }
}

void solve() {
  if ( str[ 0 ][ 0 ] == str[ 1 ][ 1 ] && str[ 0 ][ 0 ] == str[ 2 ][ 2 ] && str[ 0 ][ 0 ] != '+' ) {
    cout << str[ 0 ][ 0 ] << "\n";
    return;
  }
  if ( str[ 0 ][ 2 ] == str[ 1 ][ 1 ] && str[ 0 ][ 2 ] == str[ 2 ][ 0 ] && str[ 0 ][ 2 ] != '+' ) {
    cout << str[ 0 ][ 2 ] << "\n";
    return;
  }

  for ( int i = 0; i < 3; i++ ) {
    if ( str[ i ][ 0 ] == str[ i ][ 1 ] && str[ i ][ 0 ] == str[ i ][ 2 ] && str[ i ][ 0 ] != '+' ) {
      cout << str[ i ][ 0 ] << "\n";
      return;
    }
    if ( str[ 0 ][ i ] == str[ 1 ][ i ] && str[ 0 ][ i ] == str[ 2 ][ i ] && str[ 0 ][ i ] != '+' ) {
      cout << str[ 0 ][ i ] << "\n";
      return;
    }
  }
  cout << "NA\n";
}

int main() {
  ios::sync_with_stdio( false );
  cin.tie( 0 );
  while ( true ) {
    input();
    if ( str[ 0 ] == "0" ) {
      break;
    }
#ifdef WIN32
    clock_t stime = clock();
#endif
    solve();
#ifdef WIN32
    clock_t etime = clock();
    cerr << "TIME : " << ( double ) ( etime - stime ) / CLOCKS_PER_SEC << "\n";
#endif
  }
return 0;
}

C++: #include <iostream>

void dwrite(int i){
	std::cout << i << std::endl;
}

int main(){
	dwrite('b');
	dwrite('w');
	std::string m[3], w;
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		w = "NA";
		for(int i=0;i<3;i++){
			char c = m[i][0];
			if(2 * c - m[i][1] - m[i][2] == 0 && c - '+')w = c;
			c = m[0][i];
			if(2 * c - m[1][i] - m[2][i] == 0 && c - '+')w = c;
		}
		if(m[0][0] + m[1][1] - m[2][2] * 2 == 0 && m[0][0] - '+')w = m[0][0];
		if(m[0][2] + m[1][1] - m[2][0] * 2 == 0 && m[0][2] - '+')w = m[0][2];
		
		std::cout << w << '\n';
	}
}