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 <vector>
#include <string>
using namespace std;

int main() {
	while(1) {
		vector<string> v;
		for(int i = 0; i < 3; i++) {
			string str;
			cin >> str;
			if(str == "0")
				goto EXIT;
			v.push_back(str);
		}

		for(int i = 0; i < 2; i++) {
			bool tate, yoko;
			bool naname0, naname1;
			char c;
			naname0 = naname1 = false;
			c = i ? 'b': 'w';
			for(int j = 0; j < 3; j++) {
				tate = yoko = true;
				for(int k = 0; k < 3; k++) {
					tate &= v[k][j] == c;
					yoko &= v[j][k] == c;
				}
				naname0 &= v[j][2-j] == c;
				naname1 &= v[2-j][j] == c;
				if(tate || yoko) {
					cout << c << endl;
					goto NEXT;
				}
			}
			if(naname0 || naname1) {
				cout << c << endl;
				goto NEXT;
			}
		}
		cout << "NA" << endl;
NEXT:;
	}
EXIT:;
}

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

int main()
{
	char field[3][3];
	while(true){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				cin >> field[i][j];
				if(field[i][j] == '0')
					return 0;
			}
		}
		bool flag = false;
		for(int i=0;i<3;i++){
			if(field[i][1] == field[i][0] && field[i][1] == field[i][2] && field[i][1] != '+'){
				cout << field[i][1] << endl;
				flag = true;
				break;
			}
			if(field[1][i] == field[0][i] && field[1][i] == field[2][i] && field[i][1] != '+'){
				cout << field[1][i] << endl;
				flag = true;
				break;
			}
		}
		if(flag)
			continue;
		if((field[1][1] == field[0][0] && field[1][1] == field[2][2]) || (field[1][1] == field[2][0] && field[1][1] == field[0][2]) && field[1][1] != '+'){
			cout << field[1][1] << endl;
			continue;
		}
		cout << "NA" << endl;
	}
	return 0;
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back



int main() {
    char data[3][3];
    while(cin>>data[0][0]){
        if(data[0][0]=='0')break;
        rep(i,3){
            rep(j,3){
                if(i!=0 || j!=0){
                    cin>>data[i][j];
                }
            }
        }
        
        
        rep(i,3){
            if(data[i][0]==data[i][1] && data[i][1]==data[i][2] && data[i][0]!='+'){
                cout<<data[i][0]<<endl;
                goto next;
            }
        }

        rep(j,3){
            if(data[0][j]==data[1][j] && data[1][j]==data[2][j] && data[0][j]!='+'){
                cout<<data[0][j]<<endl;
                goto next;
            }
        }

        if( ( (data[0][0]==data[1][1] && data[1][1]==data[2][2]) || (data[0][2]==data[1][1] && data[1][1]==data[2][0]) ) && data[1][1]!='+'){
            cout<<data[1][1]<<endl;
            goto next;
        }
        
        
        cout<<"NA"<<endl;
        next:;
    }
    
    
    return 0;
}

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

using namespace std;


int main() {

  string buf;

  int board[3][3];


  while(getline(cin,buf)) {

    if(buf[0]=='0') break;

    for(int i=0;i<3;i++) {

      switch(buf[i]) {
	  
      case '+':
	board[0][i]=0;
	break;

      case 'b':
	board[0][i]=1;
	break;

      case 'w':
	board[0][i]=2;
	break;

      }

    }

    for(int i=1;i<3;i++) {

      getline(cin,buf);

      for(int j=0;j<3;j++) {

	switch(buf[j]) {
	  
	case '+':
	  board[i][j]=0;
	  break;

	case 'b':
	  board[i][j]=1;
	  break;

	case 'w':
	  board[i][j]=2;
	  break;

	}

      }

    }
    /*
    for(int i=0;i<3;i++) {

      for(int j=0;j<3;j++) cout << board[i][j];

      cout << endl;

    }
    */
    if((board[0][0]==1 && board[0][1]==1 && board[0][2]==1) || (board[1][0]==1 && board[1][1]==1 && board[1][2]==1) || (board[2][0]==1 && board[2][1]==1 && board[2][2]==1) || (board[0][0]==1 && board[1][0]==1 && board[2][0]==1) || (board[0][1]==1 && board[1][1]==1 && board[2][1]==1) || (board[0][2]==1 && board[1][2]==1 && board[2][2]==1) || (board[0][0]==1 && board[1][1]==1 && board[2][2]==1) || (board[0][2]==1 && board[1][1]==1 && board[2][0]==1)) cout << "b" << endl;

    else if((board[0][0]==2 && board[0][1]==2 && board[0][2]==2) || (board[1][0]==2 && board[1][1]==2 && board[1][2]==2) || (board[2][0]==2 && board[2][1]==2 && board[2][2]==2) || (board[0][0]==2 && board[1][0]==2 && board[2][0]==2) || (board[0][1]==2 && board[1][1]==2 && board[2][1]==2) || (board[0][2]==2 && board[1][2]==2 && board[2][2]==2) || (board[0][0]==2 && board[1][1]==2 && board[2][2]==2) || (board[0][2]==2 && board[1][1]==2 && board[2][0]==2)) cout << "w" << endl;

    else cout << "NA" << endl;

  }

  return 0;

}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char board[4][4];
int main(){
	string str;
	while(cin>>str){
		bool flag=false;
		if(str=="0")break;
		board[0][0]=str[0];
		board[0][1]=str[1];
		board[0][2]=str[2];
		for(int i =1;i <3;i++){
			for(int j =0;j <3;j++){
				cin>>board[i][j];
			}
		}
		for(int i =0;i <3;i++){
			if((board[i][0]=='b'||board[i][0]=='w')&&
			   !flag&&board[i][0]==board[i][1]&&board[i][1]==board[i][2]){
				cout <<board[i][0]<<endl;
				flag =true;
				break;
			}
		}
		if(flag)continue;
		for(int j =0;j <3;j++){
			if((board[0][j]=='b'||board[0][j]=='w')&&
			   !flag&&board[0][j]==board[1][j]&&board[1][j]==board[2][j]){
				cout <<board[0][j]<<endl;
				flag =true;
				break;
			}
		}
		if(flag)continue;
		if((board[0][0]=='b'||board[0][0]=='w')
		   &&board[0][0]==board[1][1]&&board[1][1]==board[2][2]){
			cout <<board[0][0]<<endl;
			flag=true;
			break;
		}
		if(flag)continue;
		if((board[0][2]=='b'||board[0][2]=='w')
		   &&board[0][2]==board[1][1]&&board[0][2]==board[2][0]){
			cout <<board[0][2]<<endl;
			flag =true;
			break;
		}
		if(!flag)cout <<"NA"<<endl;
	}
	return 0;
}