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>

using namespace std;


int main(){

  while(true){
    string s[3];
    cin >> s[0];
    if(s[0] == "0")break;
    cin >> s[1];
    cin >> s[2];
    if(s[0][0] == s[0][1] && s[0][1] == s[0][2] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][0] == s[1][0] && s[1][0] == s[2][0] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][1] == s[1][1] && s[1][1] == s[2][1] && s[0][1] != '+'){
      cout << s[0][1] << endl;
      continue;
    }
    if(s[0][2] == s[1][2] && s[1][2] == s[2][2] && s[0][2] != '+'){
      cout << s[0][2] << endl;
      continue;
    }
    if(s[0][2] == s[1][1] && s[1][1] == s[2][0] && s[0][2] != '+'){
      cout << s[0][2] << endl;
      continue;
    }
    if(s[1][0] == s[1][1] && s[1][1] == s[1][2] && s[1][0] != '+'){
      cout << s[1][0] << endl;
      continue;
    }
    if(s[2][0] == s[2][1] && s[2][1] == s[2][2] && s[2][0] != '+'){
      cout << s[2][0] << endl;
      continue;
    }


      cout<< "NA" << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
typedef long long ll;
typedef unsigned long long ull;
int main(){
    char stage[4][4]={{0}};
    while(scanf("%s",stage[0]), stage[0][0] != '0'){
        reps(i,1,3)scanf("%s",stage[i]);
        /*Check*/
        bool f = false;
        rep(i,3){
            if(stage[i][0] == 'b' && stage[i][1] == 'b' && stage[i][2] == 'b'){
                puts("b");
                f = true;
                break;
            }
            if(stage[i][0] == 'w' && stage[i][1] == 'w' && stage[i][2] == 'w'){
                puts("w");
                f = true;
                break;
            }
            if(stage[0][i] == 'b' && stage[1][i] == 'b' && stage[2][i] =='b'){
                puts("b");
                f = true;
                break;
            }
            if(stage[0][i] == 'w' && stage[1][i] =='w' && stage[2][i] == 'w'){
                puts("w");
                f = true;
                break;
            }
        }
        if(f)continue;
        if(stage[0][0] == stage[1][1] && stage[1][1] ==stage[2][2] &&stage[0][0] == 'b'){
            puts("b");
            f = true;
            continue;
        }
        if(stage[0][0] == stage[1][1] && stage[1][1] ==stage[2][2] &&stage[0][0] == 'w'){
            puts("w");
            f = true;
            continue;
        }
        if(stage[0][2] == stage[1][1] && stage[1][1] ==stage[2][0] &&stage[0][2] == 'b'){
            puts("b");
            f = true;
            continue;
        }
        if(stage[0][2] == stage[1][1] && stage[1][1] ==stage[2][0] &&stage[0][2] == 'w'){
            puts("w");
            f = true;
            continue;
        }
        if(!f)puts("NA");
    }
    return 0;
}

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[2][0] == 'b' && b[1][1] == 'b' && b[3][2] == '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[2][0] == 'b' && b[1][1] == 'b' && b[3][2] == 'b'){
		cout << 'w' << endl;
		check = 0; break;
			}

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

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string s[3];
	bool flg = false;
	cin >> s[0];
	if(s[0] == "0") break;
	cin >> s[1] >> s[2];
	REP(i,3)
	    if(s[i][0] == s[i][1] && s[i][0] == s[i][2]){
		if(s[i][0] == '+') continue;
		cout << s[i][0] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;
	REP(i,3)
	    if(s[0][i] == s[1][i] && s[0][i] == s[2][i]){
		if(s[0][i] == '+') continue;
		cout << s[0][i] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;

	if(s[0][0] == s[1][1] && s[0][0] == s[2][2]){
	    if(s[0][0] == '+') continue;
	    cout << s[0][0] << endl;
	    flg = true;
	}
	if(flg) continue;
	if(s[0][2] == s[1][1] && s[2][0] == s[1][1]){
	    if(s[0][2] == '+') continue;
	    cout << s[0][2] << endl;
	    flg = true;
	}
	if(flg) continue;
	cout << "NA" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
  int i, j;
  string c[3];
  char win;

  while(1){
    for(i=0; i<3; ++i){
      cin >> c[i];
      if(c[0] == "0") break;
    }
    if(c[0] == "0") break;

    win = '0';

    for(i=0; i<3; i++){
      if(c[i][0] == c[i][1] && c[i][0] == c[i][2] && c[i][0] != '+')
	win = c[i][0];
      if(c[0][i] == c[1][i] && c[0][i] == c[2][i] && c[0][i] != '+')
	win = c[0][i];
    }

    if(c[0][0] == c[1][1] && c[0][0] == c[2][2] && c[0][0] != '+')
      win = c[0][0];
    if(c[0][2] == c[1][1] && c[0][2] == c[2][0] && c[0][2] != '+')
      win = c[0][2];


    if(win == '0')
      cout << "NA" << endl;
    else
      cout << win << endl;
  }

  return 0;
}