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;
			}
		}
		if (c){
			cout << "NA" << endl;
		}
	}
	
	return (0);
}

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

int main() {
  string line;
  int a[3][3];
  int winner;
  cin >> line;
  while (1) {
    if (line == "0") {
      break;
    }
    for (int i=0; i<3; i++) {
      for (int j=0; j<3; j++) {
        char c = line[j];
        if (c == 'b') {
          a[i][j] = 1;
        } else if (c == 'w') {
          a[i][j] = -1;
        } else {
          a[i][j] = 0;
        }
      }
      cin >> line;
    }
    winner= 0;
    for (int i=0; i<3; i++) {
      if (a[i][0] && a[i][0] == a[i][1] && a[i][1] == a[i][2]) {
        winner = a[i][0];
      }
    }
    for (int j=0; j<3; j++) {
      if (a[0][j] && a[0][j] == a[1][j] && a[1][j] == a[2][j]) {
        winner = a[0][j];
      }
    }
    if (a[0][0] && a[0][0] == a[1][1] && a[1][1] == a[2][2]) {
      winner = a[0][0];
    }
    if (a[0][2] && a[0][2] == a[1][1] && a[1][1] == a[2][0]) {
      winner = a[0][2];
    }
    if (winner == 1) {
      cout << "b" << endl;
    } else if (winner == -1) {
      cout << "w" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

bool iswinner(char b[3][4],char c)
{
	int cnt=0;
	for(int i=0;i<3;i++){
		cnt=0;
		for(int j=0;j<3;j++)	if(b[i][j]==c)	cnt++;
		if(cnt==3)	return true;

		cnt=0;
		for(int j=0;j<3;j++)	if(b[j][i]==c)	cnt++;
		if(cnt==3)	return true;
	}

	cnt=0;
	for(int i=0;i<3;i++)	if(b[i][i]==c)		cnt++;
	if(cnt==3)	return true;

	cnt=0;
	for(int i=0;i<3;i++)	if(b[2-i][i]==c)	cnt++;
	if(cnt==3)	return true;

	return false;
}

int main()
{
	for(char board[3][4];cin>>board[0],board[0][0]-'0';){
		for(int i=1;i<3;i++)	cin>>board[i];
		if     (iswinner(board,'b'))	cout<<'b'<<endl;
		else if(iswinner(board,'w'))	cout<<'w'<<endl;
		else	cout<<"NA"<<endl;
	}

	return 0;
}

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

int main(void){
  string board1,board2,board3;
  while(cin>>board1>>board2>>board3){
    if(board1[0]!='+' and board1[0]==board1[1] and board1[1]==board1[2]){
      cout<<board1[0]<<endl;
      continue;
    }
    if(board2[0]!='+' and board2[0]==board2[1] and board2[1]==board2[2]){
      cout<<board2[0]<<endl;
      continue;
    }
    if(board3[0]!='+' and board3[0]==board3[1] and board3[1]==board3[2]){
      cout<<board3[0]<<endl;
      continue;
    }
    if(board1[0]!='+' and board1[0]==board2[0] and board2[0]==board3[0]){
      cout<<board1[0]<<endl;
      continue;
    }
    if(board1[1]!='+' and board1[1]==board2[1] and board2[1]==board3[1]){
      cout<<board1[1]<<endl;
      continue;
    }
    if(board1[2]!='+' and board1[2]==board2[2] and board2[2]==board3[2]){
      cout<<board1[2]<<endl;
      continue;
    }
    if(board1[0]!='+' and board1[0]==board2[1] and board2[1]==board3[2]){
      cout<<board1[0]<<endl;
      continue;
    }
    if(board1[2]!='+' and board1[2]==board2[1] and board2[1]==board3[0]){
      cout<<board1[2]<<endl;
      continue;
    }
    cout<<"NA"<<endl;
  }
  return 0;
}

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

char field[3][4];

char solve(){
	for(int i=0; i<3; i++){
		if(field[i][0] == field[i][1] && field[i][1] == field[i][2] && (field[i][0] == 'w' || field[i][0] == 'b'))
			return field[i][0];
	}
	for(int k=0; k<3; k++){
		if(field[0][k] == field[1][k] && field[1][k] == field[2][k] && (field[0][k] == 'w' || field[0][k] == 'b'))
			return field[0][k];
	}
	if(field[0][0] == field[1][1] && field[1][1] == field[2][2] && (field[0][0] == 'w' || field[0][0] == 'b'))
		return field[0][0];
	if(field[0][2] == field[1][1] && field[1][1] == field[2][0] && (field[0][2] == 'w' || field[0][2] == 'b'))
		return field[0][2];
	return 'N';
}

int main(){
	while(true){
		for(int i=0; i<3; i++){
			cin >> field[i];
			if(field[0][0] == '0')
				return 0;
		}
		char ans = solve();
		if(ans == 'N')
			cout << "NA\n";
		else
			cout << ans << endl;
	}
}

C++: 
#include<iostream>
using namespace std;
int main()
{
  char field[3][3], c;
  int i;
  while (cin>>field[0][0], field[0][0]!='0') {
    for (i = 1; i < 9; i++) cin>>field[i%3][i/3];
    c = '+';
    for (i = 0; i < 3; i++) {
      if (field[i][0] == field[i][1] && field[i][0] == field[i][2])
	c = field[i][0];
    }
    for (i = 0; i < 3; i++) {
      if (field[0][i] == field[1][i] && field[0][i] == field[2][i])
	c = field[0][i];
    }
    if (field[0][0] == field[1][1] && field[0][0] == field[2][2])
      c = field[0][0];
    if (field[2][0] == field[1][1] && field[2][0] == field[0][2])
      c = field[2][0];
    if (c == 'b' || c == 'w') cout<<c<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}

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

string a[3];

char tate(){
	for(int i=0;i<3;i++){
		if(a[0][i]==a[1][i]&&a[0][i]==a[2][i]&&a[0][i]!='+'){
			return a[0][i];
		}
	}
	return '+';
}

char yoko(){
	for(int i=0;i<3;i++){
		if(a[i][0]==a[i][1]&&a[i][0]==a[i][2]&&a[i][0]!='+'){
			return a[i][0];
		}
	}
	return '+';
}

char naname(){
	if(a[1][1]==a[2][2]&&a[1][1]==a[0][0]&&a[0][0]!='+')return a[1][1];
	else if(a[0][2]==a[1][1]&&a[1][1]==a[2][0]&&a[0][2]!='+')return a[1][1];
	return '+';
}

int main(){
	while(cin>>a[0],a[0]!="0"){
		for(int i=1;i<3;i++)cin>>a[i];
		if(tate()!='+')cout<<tate();
		else if(yoko()!='+')cout<<yoko();
		else if(naname()!='+')cout<<naname();
		else cout<<"NA";
		cout<<endl;
	}
}