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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	vector<string> v(3);
	while(1){
		rep(i,3){
			cin>>v[i];
			if(v[i][0]=='0'){
				return;
			}
		}
		int ans=0;
		rep(i,3){
			if(v[i][0]==v[i][1]&&v[i][1]==v[i][2]){
				if(v[i][0]=='b'){
					ans=1;
				}
				if(v[i][0]=='w'){
					ans=2;
				}
			}
			if(v[0][i]==v[1][i]&&v[1][i]==v[2][i]){
				if(v[0][i]=='b'){
					ans=1;
				}
				if(v[0][i]=='w'){
					ans=2;
				}
			}
		}
		if(v[0][0]==v[1][1]&&v[1][1]==v[2][2]){
			if(v[0][0]=='b'){
				ans=1;
			}
			if(v[0][0]=='w'){
				ans=2;
			}
		}
		if(v[2][0]==v[1][1]&&v[1][1]==v[0][2]){
			if(v[1][1]=='b'){
				ans=1;
			}
			if(v[1][1]=='w'){
				ans=2;
			}
		}
		if(ans==0){
			puts("NA");
		}
		if(ans==1){
			puts("b");
		}
		if(ans==2){
			puts("w");
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include<iostream>
using namespace std;
int main(void) {
	while (1) {
		char c;
		int goban[3][3] = { 0 }, result = 0, judge = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				cin >> c;
				if (c == '0') break;
				if (c == 'b')goban[i][j] = 1;
				else if (c == 'w')goban[i][j] = -1;
				else goban[i][j] = 0;
			}
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				judge += goban[i][j];
			}
			if (judge == 3) result = 1;
			else if (judge == -3) result = -1;

			judge = 0;
		}
		for (int j = 0; j < 3; j++) {
			for (int i = 0; i < 3; i++) {
				judge += goban[i][j];
			}
			if (judge == 3) result = 1;
			else if (judge == -3) result = -1;

			judge = 0;
		}
		for (int i = 0; i < 3; i++) {
			judge += goban[i][i];
			if (judge == 3) result = 1;
			else if (judge == -3) result = -1;

			judge = 0;
		}
		for (int i = 0; i < 3; i++) {
			judge += goban[i][2 - i];
			if (judge == 3) result = 1;
			else if (judge == -3) result = -1;

			judge = 0;
		}

		if (result == 1) {
			cout << "b" << endl;
		}
		else if (result == -1) {
			cout << "w" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main(){
  string b[3];
  string ans;

  for(;;){
    cin >> b[0];
    if(b[0] == "0")break;

    cin >> b[1] >> b[2];

    ans = "NA";
    for(int i=0;i<3;i++){
      if(b[0][i] == b[1][i] && b[1][i] == b[2][i]){
	if(b[0][i] == 'b')ans = "b";
	if(b[0][i] == 'w')ans = "w";
      }
      if(b[i][0] == b[i][1] && b[i][1] == b[i][2]){
	if(b[i][0] == 'b')ans = "b";
	if(b[i][0] == 'w')ans = "w";
      }
    }
    if(b[0][0] == b[1][1] && b[1][1] == b[2][2]){
      if(b[1][1] == 'b')ans = "b";
      if(b[1][1] == 'w')ans = "w";
    }
    if(b[0][2] == b[1][1] && b[1][1] == b[2][0]){
      if(b[1][1] == 'b')ans = "b";
      if(b[1][1] == 'w')ans = "w";
    }

    cout << ans << endl;
  }
}

C++: //AOJ 0183
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s[3];
	char w = 'q';
	while (1) {
		for (auto& i : s) {
			cin>>i;
			if(i == "0") return 0;
		}
		bool end = false;
		for (int i = 0; i < 3; i++) {
			char c = s[i][0];
			bool flag = true;
			for (int j = 0; j < 3; j++)
				if(s[i][j] != c) {flag = false;break;}
			if(flag && s[i][0] != '+') putchar(c),putchar('\n'),end = true;
		}
		if(end) goto fin;
		for (int i = 0; i < 3; i++) {
			char c = s[0][i];
			bool flag = true;
			for (int j = 0; j < 3; j++)
				if(s[j][i] != c) {flag = false;break;}
			if(flag && s[0][i] != '+') putchar(c),putchar('\n'),end = true;
		}
		if(end) goto fin;
		w = s[0][0];
		end = true;
		for (int i = 0; i < 3; i++)
			if(s[i][i] != w){end = false;break;}
		if(end && w != '+') {putchar(w);putchar('\n');goto fin;}
		w = s[0][2];
		end = true;
		for (int i = 0; i < 3; i++) {
			if(s[i][2-i] != w) {end = false;break;}
		}
		if(end && w != '+') putchar(w),putchar('\n');
fin:
		if(!end || w == '+') puts("NA");
	}
	return 0;
}

C++: #include<iostream>

using namespace std;


int main(){

  while(true){
    string s[3];
    cin >> s[0];
    if(s[0] == "0")break;
    cin >> s[1];
    cin >> s[2];
    if(s[0][0] == s[0][1] && s[0][1] == s[0][2] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][0] == s[1][0] && s[1][0] == s[2][0] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][1] == s[1][1] && s[1][1] == s[2][1] && s[0][1] != '+'){
      cout << s[0][1] << endl;
      continue;
    }
    if(s[0][2] == s[1][2] && s[1][2] == s[2][2] && s[0][2] != '+'){
      cout << s[0][2] << endl;
      continue;
    }
    if(s[0][2] == s[1][1] && s[1][1] == s[2][0] && s[0][2] != '+'){
      cout << s[0][2] << endl;
      continue;
    }


      cout<< "NA" << endl;
  }
  return 0;
}