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 <vector>
using namespace std;
int board[3][3];

int main(){
	char c;
 	while(cin >> c){
		
		if(c == '0'){
			return 0;
		}
		
		//テ、ツスツソテァツ板ィテ」ツδ愿」ツδシテ」ツδ嘉」ツつ?テ」ツ?ァテ・ツ按敕ヲツ慊淌・ツ個?
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				board[i][j] = 0;
			}
		}
		
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(c == 'b'){
					board[i][j] = 1;
				}else if(c == 'w'){
					board[i][j] = -1;
				}
				if((i == 2) && (j == 2)){
				}else{
					cin >> c;
				}
			}
		}
		
		int n=0;
		for(int i=0;i<3;i++){
			if((board[i][0] == board[i][1]) && (board[i][0] == board[i][2])){
				if(board[i][0] == 1){
					cout << "b" << endl;
				}else{
					cout << "w" << endl;
				}
				n = 1;
			}
		}
		for(int j=0;j<3;j++){
			if((board[0][j] == board[1][j]) && (board[0][j] == board[2][j])){
				if(board[0][j] == 1){
					cout << "b" << endl;
				}else{
					cout << "w" << endl;
				}
				n = 1;
			}
		}
		if((board[0][0] == board[1][1]) && (board[0][0] == board[2][2])){
			if(board[0][0] == 1){
				cout << "b" << endl;
			}else{
				cout << "w" << endl;
			}
			n = 1;
		}
		if((board[0][2] == board[1][1]) && (board[0][2] == board[2][0])){
			if(board[0][2] == 1){
				cout << "b" << endl;
			}else{
				cout << "w" << endl;
			}
			n = 1;
		}
		if(n == 0){
			cout << "NA" << endl;
		}
	}
		
		return 0;
}

C++: //0066's copy
#include<iostream>
#include<string>
using namespace std;
int main(){
  string in;
  while(cin>>in,in[0]!='0'){
    for(int i=0;i<2;i++){
      string tmp;
      cin>>tmp;
      in+=tmp;
    }
    string han;
    //cout<<in<<endl;
    if(
       (in[0]==in[1]&&in[1]==in[2])||
       (in[0]==in[4]&&in[4]==in[8])||
       (in[0]==in[3]&&in[3]==in[6])
       ){if(in[0]!='+')han=in[0];}
    else if((in[2]==in[4]&&in[4]==in[6])||(in[2]==in[5]&&in[5]==in[8]))
      {if(in[2]!='+')han=in[2];}
    else if(in[1]==in[4]&&in[4]==in[7]){if(in[1]!='+')han=in[1];}
    else if(in[3]==in[4]&&in[4]==in[5]){if(in[3]!='+')han=in[3];}
    else if(in[6]==in[7]&&in[7]==in[8]){if(in[6]!='+')han=in[6];}
    else han="NA";
    cout<<han<<endl;
  }

}

C++: #include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  
  char grid[3][3];
  while(1) {
    for(int i=0; i<3; i++) {
      for(int j=0; j<3; j++) {
        cin >> grid[i][j];
        if(grid[i][j] == '0') return 0;
      }
    }
    
    for(int i=0; i<3; i++) {
      bool b = 1, w = 1;
      for(int j=0; j<3; j++) {
        if(grid[i][j] == 'b') w = 0;
        else if(grid[i][j] == 'w') b = 0;
        else b = 0, w = 0;
      }
      if(b) {
        cout << 'b' << endl;
        goto EXIT;
      }
      if(w) {
        cout << 'w' << endl;
        goto EXIT;
      }
    }
    
    for(int i=0; i<3; i++) {
      bool b = 1, w = 1;
      for(int j=0; j<3; j++) {
        if(grid[j][i] == 'b') w = 0;
        else if(grid[j][i] == 'w') b = 0;
        else b = 0, w = 0;
      }
      if(b) {
        cout << 'b' << endl;
        goto EXIT;
      }
      if(w) {
        cout << 'w' << endl;
        goto EXIT;
      }
    }
    
    bool b, w;
    
    b = 1, w = 1;
    for(int i=0; i<3; i++) {
      if(grid[i][i] == 'b') w = 0;
      if(grid[i][i] == 'w') b = 0;
      else b = 0, w = 0;
    }
    if(b) {
      cout << 'b' << endl;
      goto EXIT;
    }
    if(w) {
      cout << 'w' << endl;
      goto EXIT;
    }
    
    b = 1, w = 1;
    for(int i=0; i<3; i++) {
      if(grid[i][2-i] == 'b') w = 0;
      if(grid[i][2-i] == 'w') b = 0;
      else b = 0, w = 0;
    }
    if(b) {
      cout << 'b' << endl;
      goto EXIT;
    }
    if(w) {
      cout << 'w' << endl;
      goto EXIT;
    }
    
    cout << "NA" << endl;
    
  EXIT:;
  }
  
  return 0;
}

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

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

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    char c;
    while (cin >> c, c != '0') {
        char b[3][3]; b[0][0] = c;
        for (int i = 1; i < 9; i++) {
            cin >> b[i/3][i%3];
        }
        
        auto win = [&](char c) -> bool {
            for (int i = 0; i < 3; i++) {
                if (b[i][0] == c && b[i][1] == c && b[i][2] == c) {
                    return true;
                }
                if (b[0][i] == c && b[1][i] == c && b[2][i] == c) {
                    return true;
                }
            }

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

        if (win('b')) {
            cout << 'b' << endl;
        } else if (win('w')) {
            cout << 'w' << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

int main() {
	char b[5][5];

	while (cin >> b[0] && b[0] != "0") {
		cin >> b[1] >> b[2];
		string x;
		if (b[0][0] == b[0][1] && b[0][1] == b[0][2] && b[0][0] != '+') { x = b[0][0]; }
		else if (b[1][0] == b[1][1] && b[1][1] == b[1][2] && b[1][0] != '+') { x = b[1][0]; }
		else if (b[2][0] == b[2][1] && b[2][1] == b[2][2] && b[2][0] != '+') { x = b[2][0]; }
		else if (b[0][0] == b[1][0] && b[1][0] == b[2][0] && b[0][0] != '+') { x = b[0][0]; }
		else if (b[0][1] == b[1][1] && b[1][1] == b[2][1] && b[0][1] != '+') { x = b[0][1]; }
		else if (b[0][2] == b[1][2] && b[1][2] == b[2][2] && b[0][2] != '+') { x = b[0][2]; }
		else if (b[0][0] == b[1][1] && b[1][1] == b[2][2] && b[0][0] != '+') { x = b[0][0]; }
		else if (b[0][2] == b[1][1] && b[1][1] == b[2][0] && b[0][2] != '+') { x = b[0][2]; }
		else x = "NA";
		cout << x << endl;
	}
	return 0;
}

C++: #include <iostream>
int main(){
	std::string m[3], w;
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		w = "NA";
		for(int i=0;i<3;i++){
			w = (m[i][0] + m[i][1] - m[i][2] * 2 + m[i][0] - '+')?:m[i][0];
			w = (m[0][i] + m[1][i] - m[2][i] * 2 + m[0][i] - '+')?:m[0][i];
		}
		w = (m[0][0] + m[1][1] - m[2][2] * 2 + m[0][0] - '+')?:m[0][0];
		w = (m[0][2] + m[1][1] - m[2][0] * 2 + m[0][2] - '+')?:m[0][2];
		
		std::cout << w << '\n';
	}
}