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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;}
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s[3];

  while (cin >> s[0], s[0] != "0"){
    cin >> s[1] >> s[2];
    bool flg = true;
    REP(i, 3){
      if (s[0][i] == s[1][i] && s[0][i] == s[2][i]){
        print(s[0][i]);
        flg = false;
      }
    }
    REP(i, 3){
      if (s[i][0] == s[i][1] && s[i][0] == s[i][2]){
        print(s[i][0]);
        flg = false;
      }
    }
    if (s[0][0] == s[1][1] && s[0][0] == s[2][2]){
      print(s[0][0]);
      flg = false;
    }
    if (s[0][2] == s[1][1] && s[0][2] == s[2][0]){
      print(s[0][2]);
      flg = false;
    }
    if (flg){
      print("NA");
    }
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
    char field[3][3];
    while(cin >> field[0], field[0][0] != '0'){
        bool isCorrect = true;
        for(int i=1; i < 3; i++){
            cin >> field[i];
        }

        for(int i=0; i < 3; i++){
            isCorrect = true;
            char stone = field[i][0];
            for(int j=1; j < 3; j++){
                if(stone != field[i][j]) isCorrect = false;
            }
            if(isCorrect){cout << stone << endl; break;}
        }

        for(int i=0; i < 3; i++){
            isCorrect = true;
            char stone = field[0][i];
            if(stone == '+') continue;
            for(int j=1; j < 3; j++){
                if(stone != field[j][i]) isCorrect = false;
            }
            if(isCorrect){cout << stone << endl; break;}
        }

        if(isCorrect) continue;

        char stone = field[0][0];

        if(stone == field[1][1] && stone == field[2][2] && stone != '+'){cout << stone << endl; continue;}

        stone = field[2][0];

        if(stone == field[1][1] && stone == field[0][2] && stone != '+'){cout << stone << endl; continue;}

        cout << "NA" << endl;
    }
}

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;
				}
			}
		}
		
		/*
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				cout << board[i][j] << " ";
			}
			cout << endl;
		}*/
		
		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 if(board[i][0] == -1){
					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]) && (n != 1)){
				if(board[0][j] == 1){
					cout << "b" << endl;
				}else if(board[0][j] == -1){
					cout << "w" << endl;
				}
				n = 1;
			}
		}
		if((board[1][1] == board[0][0]) && (board[1][1] == board[2][2]) && (n != 1)){
			if(board[1][1] == 1){
				cout << "b" << endl;
			}else if(board[1][1] == -1){
				cout << "w" << endl;
			}
			n = 1;
		}
		if((board[1][1] == board[0][2]) && (board[1][1] == board[2][0]) && (n != 1)){
			if(board[1][1] == 1){
				cout << "b" << endl;
			}else if(board[1][1] == -1){
				cout << "w" << endl;
			}
			n = 1;
		}
		if(n == 0){
			cout << "NA" << endl;
		}
	}
		
		return 0;
}

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]) && (n != 1)){
				if(board[0][j] == 1){
					cout << "b" << endl;
				}else{
					cout << "w" << endl;
				}
				n = 1;
			}
		}
		if((board[1][1] == board[0][0]) && (board[1][1] == board[2][2]) && (n != 1)){
			if(board[1][1] == 1){
				cout << "b" << endl;
			}else{
				cout << "w" << endl;
			}
			n = 1;
		}
		if((board[0][2] == board[1][1]) && (board[0][2] == board[2][0]) && (n != 1)){
			if(board[0][2] == 1){
				cout << "b" << endl;
			}else{
				cout << "w" << endl;
			}
			n = 1;
		}
		if(n == 0){
			cout << "NA" << endl;
		}
	}
		
		return 0;
}