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 <cstdio>
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+1)*(i+1);
      }
    }
  
    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>
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;
    }

    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;
        break;
      }
    }

    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;
        break;
      }
    }


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

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

    cout << "NA" << endl;
    break;

  }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<char> deq1;
    std::deque<char> deq2;
    std::deque<char> deq3;
    string s;
    while(cin>>s) {
        if (s=="0") {
            break;
        } else {
            for (int i=0;i<3;i++) {
                deq1.emplace_back(s.at(i));
            }
            cin>>s;
            for (int j=0;j<3;j++) {
                deq2.emplace_back(s.at(j));
            }
            cin>>s;
            for (int k=0;k<3;k++) {
                deq3.emplace_back(s.at(k));
            }
            if (deq1[0]==deq2[0]&&deq2[0]==deq3[0]&&deq1[0]!='+'&&deq2[0]!='+'&&deq3[0]!='+') {
                cout<<deq1[0]<<endl;
            } else if (deq1[1]==deq2[1]&&deq2[1]==deq3[1]&&deq1[1]!='+'&&deq2[1]!='+'&&deq3[1]!='+') {
                cout<<deq1[1]<<endl;
            } else if (deq1[2]==deq2[2]&&deq2[2]==deq3[2]&&deq1[2]!='+'&&deq2[2]!='+'&&deq3[2]!='+') {
                cout<<deq1[2]<<endl;
            } else if (deq1[0]==deq1[1]&&deq1[1]==deq1[2]&&deq1[0]!='+'&&deq1[1]!='+'&&deq1[2]!='+') {
                cout<<deq1[0]<<endl;
            } else if (deq2[0]==deq2[1]&&deq2[1]==deq2[2]&&deq2[0]!='+'&&deq2[1]!='+'&&deq2[2]!='+') {
                cout<<deq2[0]<<endl;
            } else if (deq3[0]==deq3[1]&&deq3[1]==deq3[2]&&deq3[0]!='+'&&deq3[1]!='+'&&deq3[2]!='+') {
                cout<<deq3[0]<<endl;
            } else if (deq1[0]==deq2[1]&&deq2[1]==deq3[2]&&deq1[0]!='+'&&deq2[1]!='+'&&deq3[2]!='+') {
                cout<<deq1[0]<<endl;
            } else if (deq1[2]==deq2[1]&&deq2[1]==deq3[0]&&deq1[2]!='+'&&deq2[1]!='+'&&deq3[0]!='+') {
                cout<<deq1[2]<<endl;
            } else {
                cout<<"NA"<<endl;
            }
            deq1.clear();
            deq2.clear();
            deq3.clear();
        }
    }
}

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

int main(){
	string field[3];
	while(1){
		bool b = false,w = false;
		cin >> field[0];
		if(field[0] == "0") break;
		cin >> field[1] >> field[2];
		for(int i = 0;i < 3;i++){
			if(field[i] == "bbb") b = true;
			else if(field[i] == "www") w = true;
		}
		for(int i = 0;i < 3;i++){
			bool bl = true,wh = true;
			for(int j = 0;j < 3;j++){
				if(field[j][i] != 'b') bl = false;
				if(field[j][i] != 'w') wh = false;
			}
			if(bl) b = true;
			if(wh) w = true;
		}
		if(field[0][0] == field[1][1] && field[1][1] == field[2][2]){
			if(field[0][0] == 'b') b = true;
			else if(field[0][0] == 'w') w = true;
		}
		if(field[2][0] == field[1][1] && field[1][1] == field[0][2]){
			if(field[2][0] == 'b') b = true;
			else if(field[2][0] == 'w') w = true;
		}
		if(b) cout << "b" << endl;
		else if(w) cout << "w" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

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] != '+'){
          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]){
          if (s[i][0] != '+'){
            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;
}