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 <cstdio>
#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 <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;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 MP make_pair
#define PB push_back

char ban[3][3];


main(){
  while(cin>>ban[0]){
    if(ban[0][0]=='0')break;
    cin>>ban[1];
    cin>>ban[2];


    int br=0,bl=0,wr=0,wl=0;
    rep(i,3){
      int bh=0,wh=0,bv=0,wv=0;
      rep(j,3){
        if(ban[i][j]=='b')++bh;
        if(ban[i][j]=='w')++wh;
        if(ban[j][i]=='b')++bv;
        if(ban[j][i]=='w')++wv;
      }
      if(bv==3 || bh==3){
        cout<<'b'<<endl;
        goto END;
      }
      if(wv==3 || wh==3){
        cout<<'w'<<endl;
        goto END;
      }
      if(ban[i][i]=='b')++br;
      if(ban[i][i]=='w')++wr;
      if(ban[i][2-i]=='b')++bl;
      if(ban[i][2-i]=='w')++wl;
    }

    if(br==3 || bl==3){
      cout<<'b'<<endl;
      goto END;
    }
    if(wr==3 || wl==3){
      cout<<'w'<<endl;
      goto END;
    }
    puts("NA");
END:;
  }
}

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;
		}
		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;
		}
		if(flag)continue;
		if(!flag)cout <<"NA"<<endl;
	}
	return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int dt[3][3];
  char c;
  while(1){
    bool cnt=true;
    bool br=false;
    rep(i,3){
      rep(j,3){
	cin>>c;
	if(c=='0'){
	  br=true;
	  break;
	}
	if(c=='b')dt[i][j]=2;
	else if(c=='w')dt[i][j]=1;
	else dt[i][j]=0;
      }
      if(br)break;
    }
    if(br)break;
    rep(i,3){
      if(dt[i][0]==dt[i][1] && dt[i][1]==dt[i][2]){
	if(dt[i][0]==1){
	  if(cnt)cout<<'w'<<endl;
	  cnt=false;
	}else if(dt[i][0]==2){
	  if(cnt)cout<<'b'<<endl;
	  cnt=false;
	}
      }
      if(dt[0][i]==dt[1][i] && dt[1][i]==dt[2][i]){
	if(dt[0][i]==1){
	  if(cnt)cout<<'w'<<endl;
	  cnt=false;
	}else if(dt[0][i]==2){
	  if(cnt)cout<<'b'<<endl;
	  cnt=false;
	}
      }
    }
    if((dt[0][0]==dt[1][1] && dt[1][1]==dt[2][2]) || (dt[2][0]==dt[1][1] && dt[1][1]==dt[0][2])){
      if(dt[1][1]==1){
	if(cnt)cout<<'w'<<endl;
	cnt=false;
      }else if(dt[1][1]==2){
	if(cnt)cout<<'b'<<endl;
	cnt=false;
      }
    }
    if(cnt)cout<<"NA"<<endl;
  }
  return 0;
}

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

char board[8][8] = {{'+'}};
string ans = "NA";

void winp(char c, int x, int y){
    if (board[x][y] == c && board[x+1][y] == c && board[x+2][y] == c) ans = c;
    if (board[x][y] == c && board[x+1][y+1] == c && board[x+2][y+2] == c) ans = c;
    if (board[x][y] == c && board[x][y+1] == c && board[x][y+2] == c) ans = c;
}

int main(){
    while (1){
	bool end = false;
	for (int i = 0; i < 3 && !end; i++){
	    for (int j = 0; j < 3 && !end; j++){
		cin >> board[i][j];
		if (board[0][0] == '0') end = true;
	    }
	}
	if (end) break;
	ans = "NA";
	for (int i = 0; i < 3; i++)
	    for (int j = 0; j < 3; j++)
		if (board[i][j] == 'b') winp('b', i, j);
		else if (board[i][j] == 'w') winp('w', i, j);
	
	cout << ans << endl;
    }
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	string s;
	while(cin >> s)
	{
		if(s == "0") break;
		
		vector<string> v;
		v.push_back(s);

		rep(i,2)
		{
			string temp;
			cin >> temp;
			v.push_back(temp);
		}

		bool flag = true;

		rep(i,3)
		{
			if(v[i][0] == v[i][1] && v[i][1] == v[i][2])
			{
				cout << v[i][0] << endl;
				flag = false;
				break;
			}

			if(v[0][i] == v[1][i] && v[1][i] == v[2][i])
			{
				cout << v[0][i] << endl;
				flag = false;
				break;
			}
		}

		if(flag)
		{
			if(v[0][0] == v[1][1] && v[1][1] == v[2][2])
			{
				cout << v[0][0] << endl;
				flag = false;
				break;
			}

			else if(v[2][0] == v[1][1] && v[1][1] == v[0][2])
			{
				cout << v[2][0] << endl;
				flag = false;
				break;
			}
		}

		if(flag) cout << "NA" << endl;
	}
	return 0;
}

C++: bbw
wbw
+b+
bwb
wbw
wbw
0

C++: 
#include<iostream>
using namespace std;
int main()
{
  int i;
  string s[3],ans;
  while(cin>>s[0]>>s[1]>>s[2],s[0]!="0"){
    ans="NA";
    for(i=0;i<3;i++){
      if(s[i][0]!='-' && s[i][0]==s[i][1] && s[i][0]==s[i][2])ans=s[i][0];
      if(s[0][i]!='-' && s[0][i]==s[1][i] && s[0][i]==s[2][i])ans=s[0][i];
    }
    if(s[1][1]!='-' && s[1][1]==s[1][1] && s[1][1]==s[2][2])ans=s[1][1];
    if(s[1][1]!='-' && s[1][1]==s[0][2] && s[1][1]==s[2][0])ans=s[1][1];

    cout<<ans<<endl;
  }
}