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 <cassert>// c
#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}

stringstream ss;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ss   <<fixed <<setprecision(20);
	cout <<fixed <<setprecision(20);
	cerr <<fixed <<setprecision(20);

	while(true){
		vector<string> str(3);
		REP(i,3){
			cin >> str[i];
			if(str[i]=="0") return 0;
		}

		vector<vector<pair<int,int>>> check;
		REP(y,3){
			vector<pair<int,int>> ls;
			REP(x,3)ls.push_back(make_pair(y,x));
			check.push_back(ls);
		}
		REP(x,3){
			vector<pair<int,int>> ls;
			REP(y,3)ls.push_back(make_pair(y,x));
			check.push_back(ls);
		}
		{
			vector<pair<int,int>> ls;
			REP(i,3)ls.push_back(make_pair(i,i));
			check.push_back(ls);
		}
		{
			vector<pair<int,int>> ls;
			REP(i,3)ls.push_back(make_pair(i,2-i));
			check.push_back(ls);
		}

		bool bwin=false,wwin=false;
		for(auto ls:check){
			bool ok=true;for(auto p:ls)if(str[p.first][p.second]!='b')ok=false;
			if(ok)bwin=true;
		}
		for(auto ls:check){
			bool ok=true;for(auto p:ls)if(str[p.first][p.second]!='w')ok=false;
			if(ok)wwin=true;
		}
		if(bwin == wwin){
			cout <<"NA"<<endl;
		}else if(bwin){
			cout <<"b" <<endl;
		}else if(wwin){
			cout <<"w" <<endl;
		}
	}

 	return 0;
 }

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

int v[] = {7,56,73,84,146,273,292,448};

int main() {
	char c;
	while (cin >> c, c != '0') {
		int b = c=='b';
		int w = c=='w';
		for (int i=1; i<9; ++i) {
			cin >> c;
			b = b*2+(c=='b');
			w = w*2+(c=='w');
		}
		string res = "NA";
		for (int i=0; i<8; ++i) {
			if ((b|v[i])==b) res = "b";
			if ((w|v[i])==w) res = "w";
		}
		cout << res << endl;
	}
}

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

bool iswin(vs& field,char c)
{
	int a,b;
	rep(i,3){
		a=b=0;
		rep(j,3){
			a+=field[i][j]==c;
			b+=field[j][i]==c;
		}
		if(a==3 || b==3)
			return true;
	}
	a=b=0;
	rep(i,3){
		a+=field[i][i]==c;
		b+=field[i][2-i]==c;
	}
	return a==3 || b==3;
}

int main()
{
	for(vs field(3);cin>>field[0],field[0][0]!='0';){
		cin>>field[1]>>field[2];
		bool winb=iswin(field,'b');
		bool winw=iswin(field,'w');
		if(winb)
			puts("b");
		else if(winw)
			puts("w");
		else
			puts("NA");
	}
	
	return 0;
}