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++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	char table[5][5];
	while(~scanf("%s",table)){
		if(table[0][0] == '0') break;
		for(int i=1;i<=2;i++){
			scanf("%s",table+i);
		}

		int winner=0;
		for(int i=0;i<3;i++){
			int w=0,b=0;
			for(int j=0;j<3;j++){
				if(table[i][j] == 'w') w++;
				if(table[i][j] == 'b') b++;
			}
			if(w==3) winner = 1;
			if(b==3) winner = -1;
		}

		for(int i=0;i<3;i++){
			int w=0,b=0;
			for(int j=0;j<3;j++){
				if(table[j][i] == 'w') w++;
				if(table[j][i] == 'b') b++;
			}
			if(w==3) winner = 1;
			if(b==3) winner = -1;
		}

		if(table[0][0] == table[1][1]
		&& table[1][1] == table[2][2]
		&& table[2][2] =='w') winner = 1;

		if(table[0][0] == table[1][1]
		&& table[1][1] == table[2][2]
		&& table[2][2] =='b') winner = -1;

		if(table[0][2] == table[1][1]
		&& table[1][1] == table[2][0]
		&& table[2][0] =='w') winner = 1;

		if(table[0][2] == table[1][1]
		&& table[1][1] == table[2][0]
		&& table[2][0] =='b') winner = -1;

		printf("%s\n", winner == 1 ? "w" : winner == -1 ? "b" : "NA");

	}
}

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

int main(){
	char d[9];
	string m[8]={"012","345","678","036","147","258","048","246"};
	int f;
	while(cin>>d[0],d[0]!='0'){
		for(int i=1;i<=8;i++)cin>>d[i];
		f=1;
		for(int i=0;i<8;i++){
			if(d[m[i][0]-'0']==d[m[i][1]-'0']&&d[m[i][1]-'0']==d[m[i][2]-'0']&&f&&d[m[i][0]-'0']!='+'){
				f=0;
				cout<<d[m[i][0]-'0']<<endl;
			}
			
		}
		if(f)cout<<"NA"<<endl;
	}
	
	
}

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

int main(){
	char b[3][3];
	int x,y;
	int check;
	int boolean = 1;

	while(boolean){
		x = 0;
		y = 0;
		check = 1;
		for(int i = 0; i < 3; i++){
			cin >> b[i];
			if(b[0][0] == '0'){
				 boolean = 0;
				 check = 0;
				 break;
			}
		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'b' && b[i][1] == 'b' && b[i][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'b' && b[1][i] == 'b' && b[2][i] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'b' && b[1][1] == 'b' && b[2][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][2] == 'b' && b[1][1] == 'b' && b[2][0] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}

		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'w' && b[i][1] == 'w' && b[i][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'w' && b[1][i] == 'w' && b[2][i] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'w' && b[1][1] == 'w' && b[2][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][2] == 'w' && b[1][1] == 'w' && b[2][0] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}

		}
		if(check) cout << "NA" << endl;
	}
}

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

int main(){
	char b[3][3];
	int x,y;
	int check;
	int boolean = 1;

	while(boolean){
		x = 0;
		y = 0;
		check = 1;
		for(int i = 0; i < 3; i++){
			cin >> b[i];
			if(b[0][0] == '0'){
				 boolean = 0;
				 check = 0;
				 break;
			}
		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'b' && b[i][1] == 'b' && b[i][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'b' && b[1][i] == 'b' && b[2][i] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'b' && b[1][1] == 'b' && b[2][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][2] == 'b' && b[1][1] == 'b' && b[2][0] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}

		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'w' && b[i][1] == 'w' && b[i][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'w' && b[1][i] == 'w' && b[2][i] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'w' && b[1][1] == 'w' && b[2][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][2] == 'b' && b[1][1] == 'b' && b[2][0] == 'b'){
		cout << 'w' << endl;
		check = 0; break;
			}

		}
		if(check) cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int board[3][3];

int main(){
	char c;
	cin >> c;
 	while(c != '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;
				}
				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++: // 2011/03/01 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string brd[3];
		cin >> brd[0];
		if(brd[0]=="0")
			break;

		cin >> brd[1];
		cin >> brd[2];

		if(brd[0][0]!='+'&&brd[0][0]==brd[0][1]&&brd[0][1]==brd[0][2])
			cout << brd[0][0] << endl;
		else if(brd[1][0]!='+'&&brd[1][0]==brd[1][1]&&brd[1][1]==brd[1][2])
			cout << brd[1][0] << endl;
		else if(brd[2][0]!='+'&&brd[2][0]==brd[2][1]&&brd[2][1]==brd[2][2])
			cout << brd[2][0] << endl;
		else if(brd[0][0]!='+'&&brd[0][0]==brd[1][0]&&brd[1][0]==brd[2][0])
			cout << brd[0][0] << endl;
		else if(brd[0][1]!='+'&&brd[0][1]==brd[1][1]&&brd[1][1]==brd[2][1])
			cout << brd[0][1] << endl;
		else if(brd[0][2]!='+'&&brd[0][2]==brd[1][2]&&brd[1][2]==brd[2][2])
			cout << brd[0][2] << endl;
		else if(brd[0][0]!='+'&&brd[0][0]==brd[1][1]&&brd[1][1]==brd[2][2])
			cout << brd[0][0] << endl;
		else if(brd[0][2]!='+'&&brd[0][2]==brd[1][1]&&brd[1][1]==brd[2][0])
			cout << brd[0][2] << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}