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>
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]&&t[i][0]!='+'){cout<<t[i][0]<<endl;return;}
    if(t[0][i]==t[1][i]&&t[1][i]==t[2][i]&&t[0][i]!='+'){cout<<t[0][i]<<endl;return;}
    
  }
  if(t[0][0]==t[1][1]&&t[1][1]==t[2][2]&&t[1][1]!='+'){cout<<t[0][0]<<endl;return;}
  if(t[0][2]==t[1][1]&&t[1][1]==t[2][0]&&t[1][1]!='+'){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 <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	char table[3][4];
	bool FLG;

	while(true){
		scanf("%s",table[0]);
		if(table[0][0] == '0')break;

		scanf("%s",table[1]);
		scanf("%s",table[2]);

		FLG = false;

		//?¨???¨????????????
		for(int i=0; i < 3; i++){
			if((table[i][0] == 'b' || table[i][0] == 'w') && table[i][0] == table[i][1] &&
					table[i][0] == table[i][2]){
				printf("%c\n",table[i][0]);
				FLG = true;
				break;
			}

			if((table[0][i] == 'b' || table[0][i] == 'w') && table[0][i] == table[1][i] &&
					table[0][i] == table[2][i]){
				printf("%c\n",table[0][i]);
				FLG = true;
				break;
			}
		}

		if(!FLG){
			if((table[0][0] == 'b' || table[0][0] == 'w') && table[0][0] == table[1][1] &&
					table[0][0] == table[2][2]){
				printf("%c\n",table[0][0]);
				FLG = true;
			}

			if(!FLG){
				if((table[0][2] == 'b' || table[0][2] == 'w') && table[0][2] == table[1][1] &&
						table[0][2] == table[2][0]){
					printf("%c\n",table[0][2]);
					FLG = true;
				}
			}
		}

		if(!FLG)printf("NA\n");

	}

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s[3];
  while (cin >> s[0], s[0] != "0") {
    cin >> s[1] >> s[2];
    string ans = "NA";
    for (int i = 0; i < 3; i++) {
      if (s[i][0] != '+' && s[i][0] == s[i][1] && s[i][1] == s[i][2]) {
        ans = string(1, s[i][0]);
      }
    }
    for (int i = 0; i < 3; i++) {
      if (s[0][i] != '+' && s[0][i] == s[1][i] && s[1][i] == s[2][i]) {
        ans = string(1, s[0][i]);
      }
    }
    if (s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2]) {
      ans = string(1, s[0][0]);
    }
    if (s[0][2] != '+' && s[0][2] == s[1][1] && s[1][1] == s[2][0]) {
      ans = string(1, s[0][2]);
    }
    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;

int main(){

	string str;
	while(cin>>str&&str!="0"){
		vector<string> field;
		field.push_back(str);
		for(int i = 0; i < 2; i++){
			cin>>str;
			field.push_back(str);
		}
		bool fin=false;
		// æ±
		for(int i = 0; i < 3; i++){
			bool f=false;
			char ch=field[i][0];
			for(int j = 1; j < 3; j++){
				if(ch!=field[i][j]){
					f=true;
					break;
				}
			}
			// sè
			if(!f){
				cout<<ch<<endl;
				fin=true;
				break;
			}
		}
		if(!fin){
			// ½Ä
			for(int i = 0; i < 3; i++){
				bool f=false;
				char ch=field[0][i];
				for(int j = 1; j < 3; j++){
					if(ch!=field[j][i]){
						f=true;
						break;
					}
				}
				// sè
				if(!f){
					fin=true;
					cout<<ch<<endl;
					break;
				}
			}
			if(!fin){
				// ÈÈß
				char ch=field[0][0];
				if(field[1][1]==ch&&field[2][2]==ch){
					fin=true;
					cout<<ch<<endl;
				}
				else if(field[1][1]==field[2][0]&&field[2][0]==field[0][2]){
					fin=true;
					cout<<ch<<endl;
				}
			}
			else
				cout<<"NA"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	char hyou[3][3];
	while (cin >> hyou[0][0]) {
		if (hyou[0][0] == '0') {
			break;
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i != 0 ||  j != 0) {
					cin >> hyou[i][j];
				}
			}
		}
		bool hantei = true;
		for (int i = 0; i < 3; i++) {
			if (hyou[i][0] != '+' && hyou[i][0] == hyou[i][1] && hyou[i][0] == hyou[i][2]) {
				cout << hyou[i][0] << endl;
				hantei = false;
				break;
			}
			if (hyou[0][i] != '+' && hyou[0][i] == hyou[1][i] && hyou[0][i] == hyou[2][i]) {
				cout << hyou[0][i] << endl;
				hantei = false;
				break;
			}
		}
		if (hantei) {
			if (hyou[0][0] != '+' && hyou[0][0] == hyou[1][1] && hyou[0][0] == hyou[2][2]) {
				cout << hyou[0][0] << endl;
				hantei = false;
			}
			if (hyou[0][2] != '+' && hyou[0][2] == hyou[1][1] && hyou[0][2] == hyou[2][0]) {
				cout << hyou[0][2] << endl;
				hantei = false;
			}
			if (hantei) {
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

C++: include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string str1, str2, str3;
  while (cin >> str1, str1 != "0"){
    bool b, w;
    b = w = false;
    cin >> str2 >> str3;
 
    if (str1[0] == str1[1] && str1[0] == str1[2]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str2[0] == str2[1] && str2[0] == str2[2]){
      if (str2[0] == 'b') b = true;
      if (str2[0] == 'w') w = true;
    }
    else if (str3[0] == str3[1] && str3[0] == str3[2]){
      if (str3[0] == 'b') b = true;
      if (str3[0] == 'w') w = true;
    }
    else if (str1[0] == str2[0] && str1[0] == str3[0]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str1[1] == str2[1] && str1[1] == str3[1]){
      if (str1[1] == 'b') b = true;
      if (str1[1] == 'w') w = true;
    }
    else if (str1[2] == str2[2] && str1[2] == str3[2]){
      if (str1[2] == 'b') b = true;
      if (str1[2] == 'w') w = true;
    }
    else if (str1[0] == str2[1] && str1[0] == str3[2]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str1[2] == str2[1] && str1[2] == str3[0]){
      if (str1[2] == 'b') b = true;
      if (str1[2] == 'w') w = true;
    }
 
    if (b)  cout << 'b';
    if (w) cout << 'w';
    if (!b && !w)cout << "NA";
    cout << endl;
  }
}