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 <string>
using namespace std;

int main()
{
	string s[3];
	
	while (cin >> s[0], s[0] != "0"){
		cin >> s[1] >> s[2];
		
		bool c = true;
		for (int i = 0; i < 3; i++){
			if (s[i] == "www"){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[i] == "bbb"){
				cout << "b" << endl;
				c = false;
				break;
			}
			else if (s[0][i] == 'w' && s[1][i] == 'w' && s[2][i] == 'w'){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[0][i] == 'b' && s[1][i] == 'b' && s[2][i] == 'b'){
				cout << "b" << endl;
				c = false;
				break;
			}
			else if (s[0][0] == 'w' && s[1][1] == 'w' && s[2][2] == 'w'){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[0][0] == 'b' && s[1][1] == 'b' && s[2][2] == 'b'){
				cout << "b" << endl;
				c = false;
				break;
			}
			else if (s[0][2] == 'w' && s[1][1] == 'w' && s[2][0] == 'w'){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[0][2] == 'b' && s[1][1] == 'b' && s[2][0] == 'b'){
				cout << "b" << endl;
				c = false;
				break;
			}
		}
		if (c){
			cout << "NA" << endl;
		}
	}
	
	return (0);
}

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

int main() {
	while(1) {
		vector<string> v;
		for(int i = 0; i < 3; i++) {
			string str;
			cin >> str;
			if(str == "0")
				goto EXIT;
			v.push_back(str);
		}

		for(int i = 0; i < 2; i++) {
			bool tate, yoko;
			bool naname0, naname1;
			char c;
			naname0 = naname1 = true;
			c = i ? 'b': 'w';
			for(int j = 0; j < 3; j++) {
				tate = yoko = true;
				for(int k = 0; k < 3; k++) {
					tate &= v[k][j] == c;
					yoko &= v[j][k] == c;
				}
				naname0 &= v[j][2-j] == c;
				naname1 &= v[j][j] == c;
				if(tate || yoko) {
					cout << c << endl;
					goto NEXT;
				}
			}
			if(naname0 || naname1) {
				cout << c << endl;
				goto NEXT;
			}
		}
		cout << "NA" << endl;
NEXT:;
	}
EXIT:;
}

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') return 0;
				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;
		}
	}
}

C++: #include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	
	for(;;){
		char ban[3][3];
		char result = 'N';
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				cin >> ban[i][j];
				if(ban[i][j] == '0'){
					goto FIN;
				}
			}
		}
		
		for(int i = 0; i < 3; i++){
			if(ban[i][0] == ban[i][1] && ban[i][1] == ban[i][2]){	//ツ可。ツ板サツ津ィ
				if(ban[i][0] == 'b'){
					result = 'b';
				}
				else if(ban[i][0] == 'w'){
					result = 'w';
				}
			}
		}
		for(int i = 0; i < 3; i++){
			if(ban[0][i] == ban[1][i] && ban[1][i] == ban[2][i]){	//ツ可。ツ板サツ津ィ
				if(ban[0][i] == 'b'){
					result = 'b';
				}
				else if(ban[0][i] == 'w'){
					result = 'w';
				}
			}
		}
		
		if(ban[0][0] == ban[1][1] && ban[1][1] == ban[2][2]){	//ツづ按づ按づ淞板サツ津ィ
			if(ban[0][0] == 'b'){
				result = 'b';
			}
			else if(ban[0][0] == 'w'){
				result = 'w';
			}
		}
		if(ban[0][2] == ban[1][1] && ban[1][1] == ban[2][0]){	//ツづ按づ按づ淞板サツ津ィ
			if(ban[0][2] == 'b'){
				result = 'b';
			}
			else if(ban[0][2] == 'w'){
				result = 'w';
			}
		}
		
		if(result == 'N'){
			cout << "NA" << endl;
		}
		else{
			cout << result << endl;
		}
	}
	FIN:;
	getchar();
		getchar();
			getchar();
				getchar();
					getchar();
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
char c[3]={'r','g','b'};
main(){
  string s[3];
  while(cin>>s[0],s[0][0]!='0'){
    cin>>s[1]>>s[2];
    if(s[0][0]=='b'&&s[0][1]=='b'&&s[0][2]=='b')goto B;
    if(s[1][0]=='b'&&s[1][1]=='b'&&s[1][2]=='b')goto B;
    if(s[2][0]=='b'&&s[2][1]=='b'&&s[2][2]=='b')goto B;
    if(s[0][0]=='b'&&s[1][0]=='b'&&s[2][0]=='b')goto B;
    if(s[0][1]=='b'&&s[1][1]=='b'&&s[2][1]=='b')goto B;
    if(s[0][2]=='b'&&s[1][2]=='b'&&s[2][2]=='b')goto B;
    if(s[0][0]=='b'&&s[1][1]=='b'&&s[2][2]=='b')goto B;
    if(s[0][2]=='b'&&s[1][1]=='b'&&s[2][0]=='b')goto B;
    if(s[0][0]=='w'&&s[0][1]=='w'&&s[0][2]=='w')goto W;
    if(s[1][0]=='w'&&s[1][1]=='w'&&s[1][2]=='w')goto W;
    if(s[2][0]=='w'&&s[2][1]=='w'&&s[2][2]=='w')goto W;
    if(s[0][0]=='w'&&s[1][0]=='w'&&s[2][0]=='w')goto W;
    if(s[0][1]=='w'&&s[1][1]=='w'&&s[2][1]=='w')goto W;
    if(s[0][2]=='w'&&s[1][2]=='w'&&s[2][2]=='w')goto W;
    if(s[0][0]=='w'&&s[1][1]=='w'&&s[2][2]=='w')goto W;
    if(s[0][2]=='w'&&s[1][1]=='w'&&s[2][0]=='w')goto W;
    cout<<"NA"<<endl;
    if(0)B:cout<<'b'<<endl;
    if(0)W:cout<<'w'<<endl;
  }
}

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[1] == str1[2]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str2[0] == str2[1] && str2[1] == str2[2]){
      if (str2[0] == 'b') b = true;
      if (str2[0] == 'w') w = true;
    }
    else if (str3[0] == str3[1] && str3[1] == str3[2]){
      if (str3[0] == 'b') b = true;
      if (str3[0] == 'w') w = true;
    }
    else if (str1[0] == str2[0] && str2[0] == str3[0]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str1[1] == str2[1] && str2[1] == str3[1]){
      if (str1[1] == 'b') b = true;
      if (str1[1] == 'w') w = true;
    }
    else if (str1[2] == str2[2] && str2[2] == str3[2]){
      if (str1[2] == 'b') b = true;
      if (str1[2] == 'w') w = true;
    }
    else if (str1[0] == str2[1] && str2[1] == str3[2]){
      if (str1[0] == 'b') b = true;
      if (str1[0] == 'w') w = true;
    }
    else if (str1[2] == str2[1] && str2[1] == str3[0]){
      if (str1[2] == 'b') b = true;
      if (str1[2] == 'w') w = true;
    }

    if (b)  cout << 'b';
    else if (w) cout << 'w';
    else  cout << "NA";
    cout << endl;
  }
}