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 <bits/stdc++.h>
using namespace std;

int main() {
  const static char c[2] = {'b','w'};
  while(1) {
    vector<string> s(3);
    for(int i = 0; i < 3; ++i) {
      cin >> s[i];
      if(s[i] == "0") return 0;
    }
    for(int i = 0; i < 2; ++i) {
      if(s[0][0] == c[i] && s[1][1] == c[i] && s[2][2] == c[i] ||
         s[0][2] == c[i] && s[1][1] == c[i] && s[2][0] == c[i] ||
         s[0][0] == c[i] && s[1][0] == c[i] && s[2][0] == c[i] ||
         s[0][1] == c[i] && s[1][1] == c[i] && s[2][1] == c[i] ||
         s[0][2] == c[i] && s[1][2] == c[i] && s[2][2] == c[i] ||
         s[0][0] == c[i] && s[0][1] == c[i] && s[0][2] == c[i] ||
         s[1][0] == c[i] && s[1][1] == c[i] && s[1][2] == c[i] ||
         s[2][0] == c[i] && s[2][1] == c[i] && s[2][2] == c[i] ) {
        cout << c[i] << endl;
        break;
      }
      if(i+1 == 2) cout << "NA" << endl;
    }
  }
  return 0;
}

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

char b[3][3];

bool check(char c) {
	for (int i = 0; i < 3; i++) {
		if (b[i][0] == c && b[i][0] == b[i][1] && b[i][0] == b[i][2]) return true;
		if (b[0][i] == c && b[0][i] == b[1][i] && b[0][i] == b[2][i]) return true;

	}
	if (b[0][0] == c && b[0][0] == b[1][1] && b[0][0] == b[2][2]) return true;
	if (b[0][2] == c && b[0][2] == b[1][1] && b[0][2] == b[2][0]) return true;
	return false;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while (true) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				cin >> b[i][j];
				if (b[i][j] == '0') return 0;
			}
		}

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

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

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

vector<string>sts(3);
bool check(char c) {
	for (int y = 0; y < 3; ++y) {
		bool ok = true;
		for (int x = 0; x < 3; ++x) {
			if (sts[y][x] != c)ok = false;
		}
		if (ok)return true;
	}
	for (int x = 0; x < 3; ++x) {
		bool ok = true;
		for (int y = 0; y < 3; ++y) {
			if (sts[y][x] != c)ok = false;
		}
		if (ok)return true;
	}
	{
		bool ok = true;
		for (int i = 0; i < 3; ++i) {
			if (sts[i][i] != c)ok = false;
		}
		if (ok)return true;
	}
	{
		bool ok = true;
		for (int i = 0; i < 3; ++i) {
			if (sts[i][2-i] != c)ok = false;
		}
		if (ok)return true;
	}
	return false;
	
}

int main() {
	while (cin>>sts[0]) {
		if (sts[0] == "0")break;
		for (int i = 1; i < 3; ++i) {
			cin >> sts[i];
		}
		if (check('b'))cout << "b" << endl;
		else if (check('w'))cout << "w" << endl;
		else cout << "NA" << endl;
		
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char ban[9];
  int hoge[9];
  int tmp[8][3]={{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
  while(true){
    int hatena = -1;
    cin >> ban[0];
    if(ban[0]=='0') break;
    for(int i=1;i<9;i++) cin >> ban[i];
    for(int i=0;i<9;i++) hoge[i] = (ban[i]=='b'?1:(ban[i]=='w'?-1:0));
    for(int i=0;i<8;i++){
      bool ok=false;
      int bw = 0;
      for(int j=0;j<3;j++)bw += hoge[tmp[i][j]];
      if(bw==-3){
	hatena = 1;
	break;
      }	else if(bw==3){
	hatena = 2;
	break;
      }
    }
    cout << (hatena==1?"w":(hatena==2?"b":"NA")) << endl;
  }
}

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

int main(){
    string s1,s2,s3,mas;
    bool judge;
    while(1){
        cin >> s1;
        if(s1 == "0") break;
        cin >> s2 >> s3;
        mas = s1 + s2 + s3;
        judge = false;
        for(int i=0;i<9;i+=3){
            if(mas.substr(i,3) == "bbb"){
                cout << "b" << endl;
                judge = true;
                break;
            }
            if(mas.substr(i,3) == "www"){
                cout << "w" << endl;
                judge = true;
                break;
            }
        }
        for(int i=0;i<3;i++){
            if(mas[i] == mas[i+3] && mas[i+3] == mas[i+6] && !judge && mas[i] != '+'){
                cout << mas[i] << endl;
                judge = true;
                break;
            }
        }
        if(mas[0] == mas[4] && mas[4] == mas[8] && !judge && mas[0] != '+') {
            cout << mas[0] << endl;
            judge = true;
        }
        else if(mas[2] == mas[4] && mas[4] == mas[6] && !judge && mas[2] != '+'){
            cout << mas[2] << endl;
            judge = true;
        }
        else if(!judge) cout << "NA" << endl;
    }
}