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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;}
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s[3];

  while (cin >> s[0], s[0] != "0"){
    cin >> s[1] >> s[2];
    bool flg = true;
    REP(i, 3){
      if (s[0][i] == s[1][i] && s[0][i] == s[2][i]){
        if (s[0][i] == '+') continue;
        flg = false;
        break;
      }
    }
    if (flg){
      REP(i, 3){
        if (s[i][0] == s[i][1] && s[i][0] == s[i][2]){
          if (s[i][0] == '+') continue;
          print(s[i][0]);
          flg = false;
          break;
        }
      }
    }
    if (flg){
      if (s[0][0] == s[1][1] && s[0][0] == s[2][2]){
        if (s[0][0] != '+'){
          print(s[0][0]);
          flg = false;
        }
      }
    }
    if (flg){
      if (s[0][2] == s[1][1] && s[0][2] == s[2][0]){
        if (s[0][2] != '+'){
          print(s[0][2]);
          flg = false;
        }
      }
    }
    if (flg){
      print("NA");
    }
  }

  return 0;
}

C++: #include <iostream>

int main(){
	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++){
			if(m[i][0] + m[i][1] - m[i][2] * 2 == 0 && m[i][0] - '+')w = m[i][0];
			if(m[0][i] + m[1][i] - m[2][i] * 2 == 0 && m[0][i] - '+')w = m[0][i];
		}
		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';
	}
}

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;
    string r[3];

void solve(){
    for(int 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;
                return;
            }
            if(r[0][i]==r[1][i]
            &&r[1][i]==r[2][i]
            &&r[0][i]!='+'){
                cout<<r[0][i]<<endl;
                return;
            }
        }
        if(r[0][0]==r[1][1]
        &&r[1][1]==r[2][2]
        &&r[0][0]!='+'){
            cout<<r[0][0]<<endl;
            return;
        }
        if(r[0][2]==r[1][1]
        &&r[1][1]==r[2][0]
        &&r[2][0]!='+'){
            cout<<r[2][0]<<endl;
            return;
        }
        cout<<"NA"<<endl;
}

int main(){
    int i;
    while(cin>>r[0]&&r[0]!="0"){
        for(i=1;i<3;i++) cin>>r[i];
        solve();
    }
    return 0;
}

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

bool check(char bw[3][3], char x){
	for(int i=0;i<3;i++)
		if((bw[i][0] == x) && (bw[i][1] == x) && (bw[i][2] == x))
			return true;
		else if((bw[0][i] == x) && (bw[1][i] == x) && (bw[2][i] == x))
			return true;
	
	if((bw[0][0] == x) && (bw[1][1] == x) && (bw[2][2] == x))
		return true;

	if((bw[0][2] == x) && (bw[1][1] == x) && (bw[2][0] == x))
		return true;

	return false;
}

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

		cin>>str;
		if(str == "0")
			break;

		for(int j=0;j<3;j++)
			bw[0][j] = str[j];

		for(int i=1;i<3;i++){
			cin>>str;
			for(int j=0;j<3;j++)
				bw[i][j] = str[j];
		}

		if(check(bw, 'b'))
			cout<<"b"<<endl;
		else if(check(bw, 'w'))
			cout<<"w"<<endl;
		else
			cout<<"NA"<<endl;
	}

	return 0;
}

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

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
typedef long long ll;
typedef unsigned long long ull;
int main(){
    char stage[4][4]={{0}};
    while(scanf("%s",stage[0]), stage[0][0] != '0'){
        reps(i,1,3)scanf("%s",stage[i]);
        /*Check*/
        bool f = false;
        rep(i,3){
            if(stage[i][0] == 'b' && stage[i][1] == 'b' && stage[i][2] == 'b'){
                puts("b");
                f = true;
            }
            if(stage[i][0] == 'w' && stage[i][1] == 'w' && stage[i][2] == 'w'){
                puts("w");
                f = true;
            }
            if(stage[0][i] == 'b' && stage[1][i] == 'b' && stage[2][i] =='b'){
                puts("b");
                f = true;
            }
            if(stage[0][i] == 'w' && stage[1][i] =='w' && stage[2][i] == 'w'){
                puts("w");
                f = true;
            }
        }
        if(stage[0][0] == stage[1][1] && stage[1][1] ==stage[2][2] &&stage[0][0] == 'b'){
            puts("b");
            f = true;
        }
        if(stage[0][0] == stage[1][1] && stage[1][1] ==stage[2][2] &&stage[0][0] == 'w'){
            puts("w");
            f = true;
        }
        if(stage[0][2] == stage[1][1] && stage[1][1] ==stage[1][0] &&stage[0][2] == 'b'){
            puts("b");
            f = true;
        }
        if(stage[0][2] == stage[1][1] && stage[1][1] ==stage[1][0] &&stage[0][2] == 'w'){
            puts("w");
            f = true;
        }
        if(!f)puts("NA");
    }
    return 0;
}