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<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  char buff[3][4];

  while(cin >> buff[0], buff[0][0] != '0'){
    cin >> buff[1];
    cin >> buff[2];

    char ans = 0;

    REP(i,3){
      if(buff[i][0] != '+' && 
	 buff[i][0] == buff[i][1] &&
	 buff[i][0] == buff[i][2])
	ans = buff[i][0];
      if(buff[0][i] != '+' && 
	 buff[0][i] == buff[1][i] &&
	 buff[0][i] == buff[2][i])
	ans = buff[0][i];
      if(buff[0][0] != '+' && 
	 buff[0][0] == buff[1][1] &&
	 buff[0][0] == buff[2][2])
	ans = buff[0][0];
      if(buff[2][0] != '+' && 
	 buff[2][0] == buff[1][1] &&
	 buff[2][0] == buff[0][2])
	ans = buff[2][0];
    }

    if(ans != 0) cout << ans << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string s[3];
	bool flg = false;
	cin >> s[0];
	if(s[0] == "0") break;
	cin >> s[1] >> s[2];
	REP(i,3)
	    if(s[i][0] == s[i][1] && s[i][0] == s[i][2]){
		if(s[i][0] == '+') continue;
		cout << s[i][0] << endl;
		flg = true;
	    }
	if(flg) continue;
	REP(i,3)
	    if(s[0][i] == s[1][i] && s[0][i] == s[2][i]){
		if(s[0][i] == '+') continue;
		cout << s[0][i] << endl;
		flg = true;
	    }
	if(flg) continue;

	if(s[0][0] == s[1][1] && s[0][0] == s[2][2]){
	    if(s[0][0] == '+') continue;
	    cout << s[0][0] << endl;
	    flg = true;
	}
	if(flg) continue;
	if(s[0][2] == s[1][1] && s[2][0] == s[1][1]){
	    if(s[0][2] == '+') continue;
	    cout << s[0][2] << endl;
	    flg = true;
	}
	if(flg) continue;
	cout << "NA" << endl;
    }
    return 0;
}

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

const int dy[8] = {-1,-1,0,1,1,1,0,-1}, dx[8] = {0,1,1,1,0,-1,-1,-1};

int main(){
	char fld[3][3];
	while(true){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				cin>>fld[i][j];
				if(fld[i][j]=='0') return 0;
			}
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(fld[i][j]=='+') continue;
				for(int k=0;k<8;k++){
					int cnt = 0;
					for(int l=0;;l++){
						int ny = i+dy[k]*l, nx = j+dx[k]*l;
						if(ny<0 || 3<=ny || nx<0 || 3<=nx) break;
						if(fld[ny][nx]==fld[i][j]) cnt++;
					}
					if(cnt==3){
						if(fld[i][j]=='b') puts("b");
						else puts("w");
						goto NEXT;
					}
				}
			}
		}
		puts("NA");
		NEXT:;
	}
	return 0;
}

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

int main(){
	char board[3][4];
	int i;
	char w;
	while(true){
		w='0';
		for(i=0;i<3;i++){
			cin>>board[i];
			if(board[i][0] == '0' && board[i][1] == '\0'){
				break;
			}
		}
		if(i<3) break;
		for(i=0;i<3;i++){
			if(board[i][0]==board[i][1] && board[i][0]==board[i][2] && board[i][0] != '+'){
				w=board[i][0];
				break;
			}
		}
		for(i=0;i<3;i++){
			if(board[0][i]==board[1][i] && board[0][i]==board[2][i] && board[0][i] != '+'){
				w=board[0][i];
				break;
			}
		}
		if(board[0][0] == board[1][1] && board[0][0] == board[2][2] && board[0][0] != '+'){
			w=board[0][0];
		}
		if(board[0][2] == board[1][1] && board[0][2] == board[2][0] && board[0][2] != '+'){
			w=board[0][2];
		}
		switch(w){
			case '0': cout << "NA\n"; break;
			case 'b': cout << "b\n"; break;
			case 'w': cout << "w\n"; break;
		}
	}
	return 0;
}

C++: 
#include<iostream>
using namespace std;
int main()
{
  char field[3][3], c;
  int i;
  int j;
  while (cin>>field[0][0], field[0][0]!='0') {
    for (i = 1; i < 9; i++) cin>>field[i%3][i/3];
    c = '+';
    for (i = 0; i < 3; i++) {
      if ((field[i][0] == field[i][1]) && (field[i][0] == field[i][2]))
	c = field[i][0];
    }
    for (i = 0; i < 3; i++) {
      if ((field[0][i] == field[1][i]) && (field[0][i] == field[2][i]))
	c = field[0][i];
    }
    if ((field[0][0] == field[1][1]) && (field[0][0] == field[2][2]))
      c = field[0][0];
    if ((field[2][0] == field[1][1]) && (field[2][0] == field[0][2]))
      c = field[2][0];
    if (c == 'b' || c == 'w') cout<<c<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    vector<string> field(3);
    string s;
    while (cin >> s, s != "0") {
        field[0] = s;
        cin >> field[1];
        cin >> field[2];

        string res = "NA";
        for (int i = 0; i < 3; i++) {
            if (field[i] == "www") {
                res = "w";
                break;
            } else if (field[i] == "bbb") {
                res = "b";
                break;
            }
        }
    
        for (int i = 0; i < 3; i++) {
            if (field[0][i] == field[1][i] && field[1][i] == field[2][i]) {
                if (field[0][i] == 'w') {
                    res = "w";
                    break;
                } else if (field[0][i] == 'b') {
                    res = "b";
                    break;
                }
            }
        }
    
        if (field[0][0] == field[1][1] && field[1][1] == field[2][2]) {
            if (field[0][0] == 'w') res = "w";
            else if (field[0][0] == 'b') res = "b";
        }
    
        if (field[0][2] == field[1][1] && field[1][1] == field[2][0]) {
            if (field[0][2] == 'w') res = "w";
            else if(field[0][2] == 'b') res = "b";
        }
    
        cout << res << endl;
    }
    return 0;
}