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;
const int black =  1;
const int white =  0;
const int NaN   = -1;

int check(string f[]){

	if( f[0][0] == f[1][1] && f[1][1] == f[2][2]){
		if( f[0][0] == 'w' ) return white;
		if( f[0][0] == 'b' ) return black;
	}
	
	for(int i=0 ; i<3 ; i++){
		if( f[i][0] == f[i][1] && f[i][1] == f[i][2]){
			if( f[i][0] == 'w' ) return white;
			if( f[i][0] == 'b' ) return black;
		}
		if( f[0][i] == f[1][i] && f[1][i] == f[2][i]){
			if( f[0][i] == 'w' ) return white;
			if( f[0][i] == 'b' ) return black;
		}
	}
	return NaN;
}

int main(){
	string map[3];
	bool flag = true;
	
	while(flag){
		for(int i=0 ; i<3 ; i++){
			cin >> map[i];
			if( map[i] == "0" ){
				flag = false;
				break;
			}
		}
		if(flag == false) break;
		
		if( check( map ) == white){
			cout << "w" << endl;
		}else if( check( map ) == black){
			cout << "b" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

string f(vs s) {
  rep(i, 3) {
    if (s[i][0] == s[i][1] && s[i][1] == s[i][2]) return s[i][2] == 'b' ? "b" : "w";
    if (s[0][i] == s[1][i] && s[1][i] == s[2][i]) return s[2][i] == 'b' ? "b" : "w";
  }
  if (s[0][0] == s[1][1] && s[1][1] == s[2][2]) return s[2][2] == 'b' ? "b" : "w";
  if (s[0][2] == s[1][1] && s[1][1] == s[2][0]) return s[2][0] == 'b' ? "b" : "w";
  return "NA";
}

void solve() {
  vs s(3);
  while (cin >> s[0], s[0] != "0") {
    cin >> s[1] >> s[2];
    cout << f(s) << endl;
  }
}

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

int main(){

  int i,j;
  char g[3][3];
  char win;
  
  while(1){
    
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	cin >> g[i][j];
	if(g[0][0]=='0') return 0;
	if(g[i][j]=='+') g[i][j]=j*i;
      }
    }
  
    for(i=0;i<3;i++){
      if(g[i][0]==g[i][1] && g[i][0]==g[i][2]){
	win = g[i][0];
	break;
      }else if(g[0][i]==g[1][i] && g[0][i]==g[2][i]){
	win = g[0][i];
	break;
      }else if(g[0][0]==g[1][1] && g[0][0]==g[2][2]){
	win = g[0][0];
	break;
      }else if(g[0][2]==g[1][1] && g[0][2]==g[2][0]){
	win = g[0][2];
	break;
      }
      
    }
    
    if(i!=3) printf("%c\n",win);
    else puts("NA");

  }

    return 0;
}

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

#define BLACK 'b'
#define WHITE 'w'
#define SPACE '+'

using namespace std;


char isWin(string data[3]) {
  char temp;
  temp = data[0][0];
  if(temp != SPACE && data[1][1] == temp && data[2][2] == temp) return temp;
  temp = data[2][0];
  if(temp != SPACE && data[1][1] == temp && data[0][3] == temp) return temp;

  for(int i = 0; i < 3; i++) {
    temp = data[i][0];
    if(temp == SPACE) continue;
    bool flag = true;
    for(int j = 0; j < 3; j++) {
      if(data[i][j] != temp) {
	 flag = false;
	 break;
      }
    }
    if(flag) {
      return temp;
    }
  }

  for(int i = 0; i < 3; i++) {
    temp = data[0][i];
    if(temp == SPACE) continue;
    bool flag = true;
    for(int j = 0; j < 3; j++) {
      if(data[j][i] != temp) {
	 flag = false;
	 break;
      }
    }
    if(flag) {
      return temp;
    }
  }

  return SPACE;
}

int main() {
  while(1) {
    string data[3];
    getline(cin, data[0]);
    if(data[0] == "0") break;
    for(int i = 1; i < 3; i++) {
      getline(cin, data[i]);
    }

    char temp = isWin(data);
    if(temp == SPACE) {
      cout << "NA" << endl;
    } else {
      cout << temp << endl;
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
	string s[3];

	while (cin >> s[0], s[0] != "0")
	{
		cin >> s[1] >> s[2];
	
		if (s[0][0] == s[0][1] && s[0][1] == s[0][2] && s[0][0] != '+')
		{
			cout << s[0][0] << endl;
		}
		else if (s[1][0] == s[1][1] && s[1][1] == s[1][2] && s[1][0] != '+')
		{
			cout << s[1][0] << endl;
		}
		else if (s[2][0] == s[2][1] && s[2][1] == s[2][2] && s[2][0] != '+')
		{
			cout << s[2][0] << endl;
		}
		else if (s[0][0] == s[1][0] && s[1][0] == s[2][0] && s[0][0] != '+')
		{
			cout << s[0][0] << endl;
		}
		else if (s[0][1] == s[1][1] && s[1][1] == s[2][1] && s[0][1] != '+')
		{
			cout << s[0][1] << endl;
		}
		else if (s[0][2] == s[1][2] && s[1][2] == s[2][2] && s[0][2] != '+')
		{
			cout << s[0][2] << endl;
		}
		else if (s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[0][0] != '+')
		{
			cout << s[0][0] << endl;
		}
		else if (s[0][2] == s[1][1] && s[1][1] == s[2][0] && s[0][2] != '+')
		{
			cout << s[0][2] << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}

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

char T[3][3];

string blackwhite() {
	for (int i = 0; i < 3; i++) {
		if (T[i][0] == T[i][1] && T[i][1] == T[i][2]) {
			if (T[i][0] == 'b') { return "b"; }
			if (T[i][0] == 'w') { return "w"; }
		}
	}
	for (int i = 0; i < 3; i++) {
		if (T[0][i] == T[1][i] && T[1][i] == T[2][i]) {
			if (T[0][i] == 'b') { return "b"; }
			if (T[0][i] == 'w') { return "w"; }
		}
	}
	if (T[0][0] == T[1][1] && T[1][1] == T[2][2]) {
		if (T[0][0] == 'b') { return "b"; }
		if (T[0][0] == 'w') { return "w"; }
	}
	if (T[0][2] == T[1][1] && T[1][1] && T[2][0]) {
		if (T[0][0] == 'b') { return "b"; }
		if (T[0][0] == 'w') { return "w"; }
	}
	return "NA";
}

int main() {
	while (true) {
		cin >> T[0][0];
		if (T[0][0] == '0') { break; }
		cin >> T[0][1];
		cin >> T[0][2];
		for (int i = 1; i < 3; i++) {
			for (int j = 0; j < 3; j++){
				cin>>T[i][j];
			}
		}
		cout << blackwhite() << endl;
	}
}