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;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r.begin()); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v){ return accumulate(v.begin(), v.end()); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Field {
  Field(int w, int h) : w(w), h(h) {}
  bool invalid(int x, int y){ return x < 0 || w <= x || y < 0 || h <= y; }
  const int w, h;
};

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int masks[] = {0700, 0070, 0007, 0444, 0222, 0111, 0124, 0421};
  string s;
  while (cin >> s, s != "0"){
    vector<string> f;
    f.push_back(s);
    cin >> s;
    f.push_back(s);
    cin >> s;
    f.push_back(s);
    int black = 0;
    int white = 0;
    for (int y = 0; y < 3; y++){
      for (int x = 0; x < 3; x++){
        char c = f[y][x];
        if (c == 'w'){
          white |= 1 << (y * 3 + x);
        }
        else if (c == 'b'){
          black |= 1 << (y * 3 + x);
        }
      }
    }
    bool na = false;
    for (int i = 0; i < 8; i++){
      if ((white & masks[i]) == masks[i]){
        puts("w");
        break;
      }
      if ((black & masks[i]) == masks[i]){
        puts("b");
        break;
      }
      if (i == 7) na = true;
    }
    if (na) puts("NA");
  }
  return (0);
}

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][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;
    }


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

C++: #include <iostream>

using namespace std;

int main(){
  string s[3];

  while(cin >> s[0], s[0] != "0"){
    for(int i = 1 ; i < 3 ; i++){
      cin >> s[i];
    }   

    bool end = false;
    for(int i = 0 ; i < 3 ; i++){
      char ch = s[i][0];
      bool ok = true;
      for(int j = 1 ; j < 3 ; j++){
	if(s[i][j] != ch || s[i][j] == '+'){
	  ok = false;
	  break;
	}
      }
      if(ok){
	cout << ch << endl;
	end = true;
	break;
      }
    }

    if(end){
      continue;
    }  

    for(int i = 0 ; i < 3 ; i++){
      char ch = s[0][i];
      bool ok = true;
      for(int j = 1 ; j < 3 ; j++){
	if(s[j][i] != ch || s[j][i] == '+'){
	  ok = false;
	  break;
	}
      }
      if(ok){
	cout << ch << endl;
	end = true;
	break;
      }
    }
    if(end){
      continue;
    }

    char ch = s[0][0];
    bool ok = true;
    for(int i = 1 ; i < 3 ; i++){
      if(ch != s[i][i] || ch == '+'){
	ok = false;
	break;
      }
    }

    if(ok){
      cout << ch << endl;
      continue;
    }

    ch = s[0][2];
    for(int i = 1 ; i < 3 ; i++){
      if(ch != s[i][2-i] || ch == '+'){
	ok = false;
	break;
      }
    }

    if(ok){
      cout << ch << endl;
      break;
    }
    cout << "NA" << endl;
  }

  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;
			}
		}
		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(check) cout << "NA" << endl;
	}
}

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";
		char c;
		for(int i=0;i<3;i++){
			c = m[i][0];
			if(2*c - m[i][1] - m[i][2] == 0 && c - '+')w = c;
			c = m[0][i];
			if(2*c - m[1][i] - m[2][i] == 0 && c - '+')w = c;
		}
		c = m[0][0];
		if(2*c - m[1][1] - m[2][2] == 0 && c - '+')w = c;
		c = m[0][2];
		if(2*c - m[1][1] - m[2][0] == 0 && c - '+')w = c;
		
		std::cout << w << '\n';
	}
}

C++: #include <iostream>
using namespace std;
 
int main(){
	char m[9];
	while(1){
		for(int i=0;i<9;i++){
			cin >> m[i];
			if(m[i]=='0')return 0;
		}
		string win = "NA";
		for(int i=0;i<3;i++){
			if(m[i*3]!='+' && m[i*3]==m[i*3+1] && m[i*3+1]==m[i*3+2])
				win = m[i*3];
			if(m[ i ]!='+' && m[ i ]==m[ i+3 ] && m[ i+3 ]==m[ i+6 ])
				win = m[i];
		}
		if(m[4]!='+' && m[0]==m[4] && m[4]==m[8])
			win = m[4];
		if(m[4]!='+' && m[2]==m[4] && m[4]==m[6])
			win = m[4];
 
		cout << win << endl;		
	}
}