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++: //38
#include<iostream>

using namespace std;

int main(){
  for(;;){
    char g[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	cin>>g[i][j];
	if(g[i][j]=='0')return 0;
      }
    }
    for(int i=0;i<3;i++){
      if(g[i][0]!='+'&&g[i][0]==g[i][1]&&g[i][0]==g[i][2]){
	cout<<g[i][0]<<endl;
	goto next;
      }
      if(g[0][i]!='+'&&g[0][i]==g[1][i]&&g[0][i]==g[2][i]){
	cout<<g[0][i]<<endl;
	goto next;
      }
    }
    if(g[1][1]!='+'){
      if((g[0][0]==g[1][1]&&g[2][2]==g[1][1])||(g[0][2]==g[1][1]&&g[2][0]==g[1][1])){
	cout<<g[1][1]<<endl;
	goto next;
      }
    }
    cout<<"NA"<<endl;
    continue;
  next:
    ;
  }
  return 0;
}

C++: #include <cstdio>

int main(){
	char tbl[3][3];
	bool ok, end = false;
	
	for(;;){
		ok = false;
		for(int i = 0; i < 3; i++){
			scanf("%s", &tbl[i]);
			if(tbl[0][0] == '0'){
				end = true;
				break;
			}
		}
		if(end) break;
		if(tbl[0][0] != '+' && tbl[0][0] == tbl[1][1] && tbl[0][0] == tbl[2][2] 
			|| tbl[0][2] == tbl[1][1] && tbl[0][2] == tbl[2][0]){
			printf("%c\n", tbl[1][1]);
			ok = true;
		}else {
			for(int i = 0; i < 3; i++){
				if(tbl[0][0] != '+' && tbl[i][0] == tbl[i][1] && tbl[i][0] == tbl[i][2]){
					printf("%c\n", tbl[i][0]);
					ok = true;
					break;
				}
				if(tbl[0][0] != '+' && tbl[0][i] == tbl[1][i] && tbl[0][i] == tbl[2][i]){
					printf("%c\n", tbl[0][i]);
					ok = true;
					break;
				}
			}
		}
		if(!ok) printf("NA\n");
	}	
	return 0;
}

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

int main() {
  string str[3];
  while(1) {

    for(int i=0;i<3;i++) {
      getline(cin,str[i]);
      if(cin.eof()) return 0;
      //      cout << str[i] << endl;
    }

    bool r = false;
    for(int i=0;i<3;i++) { //yoko
      if(str[i][0] == str[i][1] && str[i][1] == str[i][2] && str[i][0] != '+') {
        cout << str[i][0] << endl;
        r = true;
        break;
      }
    }

    if(r) continue;

    for(int i=0;i<3;i++) { //tate
      if(str[0][i] == str[1][i] && str[1][i] == str[2][i] && str[0][i] != '+') {
        cout << str[0][i] << endl;
        r = true;
        break;
      }
    }

    if(r) continue;

    if(str[0][0] == str[1][1] && str[1][1] == str[2][2] && str[0][0] != '+') {  //naname
      cout << str[0][0] << endl;
      continue;
    }

    if(str[0][2] == str[1][1] && str[1][1] == str[2][0] && str[0][2] != '+') {  //naname
      cout << str[0][2] << endl;
      continue;
    }

    cout << "NA" << endl;
    continue;

  }
}

C++: #include <cstdio>
#include <utility>
#include <cctype>
#include <string>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (;;) {
		string t[3] = {in, in, in};
		if (t[0] == "0")
			break;
		auto check = [&](int ai, int aj, int bi, int bj, int ci, int cj){
			return t[ai][aj] != '+' && t[ai][aj] == t[bi][bj] && t[ai][aj] == t[ci][cj];
		};
		outl([&] () -> string {
			 for (int i: range(3))
				if (t[i] == "bbb" || t[i] == "www")
					return {t[i][0]};
				else if (check(0, i, 1, i, 2, i))
					return {t[0][i]};
			return check(0, 0, 1, 1, 2, 2) || check(2, 0, 1, 1, 0, 2) ? string {t[1][1]} : "NA";
			}());
	}
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

void solve(string s){
    int x[8][3] = {{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
    for (int i = 0; i < 8; ++i) {
        if(s[x[i][0]] == s[x[i][1]] && s[x[i][1]] == s[x[i][2]]){
            if(s[x[i][0]] != '+'){
                cout << s[x[i][0]] << "\n";
                return;
            }
        }
    }
    cout << "NA" << "\n";
    return;
}

int main() {
    string s, t, u;
    while(cin >> s, s != "0"){
        cin >> t >> u;
        solve(s+t+u);
    }
    return 0;
}