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 s,t;
	while(cin >> s, s!="0")
	{
		for(int i=0; i<2; i++)
		{
			cin >> t;
			s+=t;
		}
		int b=0, w=0;
		for(int i=0; i<9; i++)
		{
			if(s[i] == 'b') b++;
			if(s[i] == 'w') w++;
		}
		bool bw=false, ww=false;
		for(int i=0; i<9; i+=3)
		{
			if(s[i] == 'b' && s[i+1] == 'b' && s[i+2] == 'b') bw=true;
			if(s[i] == 'w' && s[i+1] == 'w' && s[i+2] == 'w') ww=true;
		}
		for(int i=0; i<3; i++)
		{
			if(s[i] == 'b' && s[i+3] == 'b' && s[i+6] == 'b') bw=true;
			if(s[i] == 'w' && s[i+3] == 'w' && s[i+6] == 'w') ww=true;
		}
		if(s[0] == 'b' && s[4] == 'b' && s[8] == 'b') bw=true;
		if(s[0] == 'w' && s[4] == 'w' && s[8] == 'w') ww=true;
		if(s[2] == 'b' && s[4] == 'b' && s[6] == 'b') bw=true;
		if(s[2] == 'w' && s[4] == 'w' && s[6] == 'w') ww=true;
		
		cout << (bw?"b":ww?"w":"NA") << endl;
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  string b[3],s;
  while(1){
    cin>>b[0];
    s="";
    if(b[0]=="0")
      break;
    cin>>b[1];
    cin>>b[2];
    int flag=0;
    for(int i=0;i<3;i++){
      if(b[0].at(i)==b[1].at(i)&&b[2].at(i)==b[1].at(i)&&b[0].at(i)!='+') s=b[0].at(i);
      if(b[i].at(0)==b[i].at(1)&&b[i].at(1)==b[i].at(2)&&b[i].at(0)!='+') s=b[i].at(0);
    }
    if(b[0].at(0)==b[1].at(1)&&b[1].at(1)==b[2].at(2)&&b[0].at(0)!='+') s=b[0].at(0);
    if(b[0].at(2)==b[1].at(1)&&b[1].at(1)==b[2].at(0)&&b[0].at(2)!='+') s=b[0].at(2);

    if(s=="b"||s=="w") cout<<s<<endl;
    else cout<<"NA"<<endl;
  }
}

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]){
        print(s[0][i]);
        flg = false;
        break;
      }
    }
    if (flg){
      REP(i, 3){
        if (s[i][0] == s[i][1] && s[i][0] == s[i][2]){
          print(s[i][0]);
          flg = false;
        }
        break;
      }
    }
    if (flg){
      if (s[0][0] == s[1][1] && s[0][0] == s[2][2]){
        print(s[0][0]);
        flg = false;
      }
    }
    if (flg){
      if (s[0][2] == s[1][1] && s[0][2] == s[2][0]){
        print(s[0][2]);
        flg = false;
      }
    }
    if (flg){
      print("NA");
    }
  }

  return 0;
}

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] && s[i][2] != '+') return s[i][2] == 'b' ? "b" : "w";
    if (s[0][i] == s[1][i] && s[1][i] == s[2][i] && s[2][i] != '+') return s[2][i] == 'b' ? "b" : "w";
  }
  if (s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[2][2] != '+') return s[2][2] == 'b' ? "b" : "w";
  if (s[0][2] == s[1][1] && s[1][1] == s[2][0] && 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;
  }
}