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<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s[3];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    cin >> s[0] >> s[1] >> s[2];
    if(s[0][0] == '0')break;

    rep(i, 3){
      rep(j, 3)if(s[i][0] != s[i][j])break;
      if(j == 3){
        cout << s[i][0] << endl;
        break;
      }
      rep(j, 3)if(s[0][i] != s[j][i])break;
      if(j == 3){
        cout << s[0][i] << endl;
        break;
      }
    }
    if(i == 3){
      if(s[0][0] == s[1][1] && s[1][1] == s[2][2]){
        cout << s[0][0] << endl;
        continue;
      }
      if(s[0][2] == s[1][1] && s[1][1] == s[2][0]){
        cout << s[0][0] << endl;
        continue;
      }
      puts("NA");
    }



//*/

//*/ break;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  char in[3][3];
  while(cin>>in[0],in[0][0]!='0'){
    rep(i,2)cin>>in[i+1];
    bool h=false;
    rep(i,3){
      if(in[0][i]==in[1][i]&&in[1][i]==in[2][i]&&in[2][i]==in[0][i]&&in[0][i]!='+'){cout<<in[0][i]<<endl;h=true;}
      if(in[i][0]==in[i][1]&&in[i][1]==in[i][2]&&in[i][2]==in[i][0]&&in[i][0]!='+'){cout<<in[i][0]<<endl;h=true;}
    }
    if(!h){
      if(in[0][0]==in[1][1]&&in[1][1]==in[2][2]&&in[2][2]==in[0][0]&&in[0][0]!='+')cout<<in[0][0]<<endl;
      else if(in[2][0]==in[1][1]&&in[1][1]==in[0][2]&&in[0][2]==in[2][0]&&in[1][1]!='+')cout<<in[1][1]<<endl;
      else cout<<"NA"<<endl;
    }
  }


}

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,3-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>
using namespace std;
string t[3];

void solve(){
  for(int i=0;i<3;i++){
    if(t[i][0]==t[i][1]&&t[i][1]==t[i][2]){cout<<t[i][0]<<endl;return;}
    if(t[0][i]==t[1][i]&&t[1][i]==t[2][i]){cout<<t[0][i]<<endl;return;}
    
  }
  if(t[0][0]==t[1][1]&&t[1][1]==t[2][2]){cout<<t[0][0]<<endl;return;}
  if(t[0][2]==t[1][1]&&t[1][1]==t[2][0]){cout<<t[0][2]<<endl;return;}
  cout<<"NA"<<endl;
}


int main(){
  while(cin>>t[0]&&t[0]!="0"){
    for(int i=1;i<3;i++)cin>>t[i];
    solve();
  }
  return 0;
}

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

int main(){

	int cnt_b, cnt_w;
	char c[3][3];
	
	while(cin >> c[0][0]){
		if(c[0][0] == '0') break;
		
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(i != 0 || j != 0){
					cin >> c[i][j];
				}
			}
		}
		
	
		if(c[0][0] == c[1][1] && c[1][1] == c[2][2] ||
			 c[2][0] == c[1][1] && c[1][1] == c[0][2]){
			if(c[1][1] != '+') cout << c[1][1] << endl;
			else cout << "NA" << endl;
		}
		else {
			for(int i=0; i<3; i++){
				if(c[i][0] == c[i][1] && c[i][1] == c[i][2] || 
					 c[0][i] == c[1][i] && c[1][i] == c[2][i]){
					if(c[i][i] != '+'){
						cout << c[i][i] << endl;
						break;
					}
					else {
						cout << "NA" << endl;
						break;
					}
				}
				if(i == 2) cout << "NA" << endl;
			}
		}
		
	}

	return 0;

}