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<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  int out = 0, base = 0,point = 0;
  int n;
  cin>>n;
  int i=0;
  while(true){
    i++;if(i>20)break;
    string s;
    cin>>s;
    //cout<<s<<endl;
    
    if(s=="OUT"){
      out++;
      //cout<<out<<endl;
      if(out==3){
	//cout<<"poin"<<endl<<endl;;
	cout<<point<<endl;
	point=0;
	out = 0;
	base = 0;
	n--;
	if(n==0)break;
      }
    }
    else if(s=="HIT"){
      base++;
      //cout<<base<<endl;
      if(base>=4){
	//cout<<base<<" "<<point<<endl;
	point++;
	base--;
	//cout<<base<<" "<<point<<endl;
      }
    }
    
    if(s=="HOMERUN"){
      point += base+1;
      base = 0;
		     
    }
    
  }
  return 0;
}

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;
        break;
      }
    }
    if (flg){
      REP(i, 3){
        if (s[i][0] == s[i][1] && s[i][0] == s[i][2]){
          print(s[i][0]);
          flg = false;
          break;
        }
      }
    }
    if (flg){
      if (s[0][0] == s[1][1] && s[0][0] == s[2][2]){
        print(s[0][0]);
        flg = false;
      }
    }
    if (flg){
      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 <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	string str;
	while(cin>>str&&str!="0"){
		vector<string> field;
		field.push_back(str);
		for(int i = 0; i < 2; i++){
			cin>>str;
			field.push_back(str);
		}
		bool fin=false;
		// æ±
		for(int i = 0; i < 3; i++){
			bool f=false;
			char ch=field[i][0];
			if(ch!='+'){
				for(int j = 1; j < 3; j++){
					if(ch!=field[i][j]){
						f=true;
						break;
					}
				}
				// sè
				if(!f){
					cout<<ch<<endl;
					fin=true;
					break;
				}
			}
		}
		if(!fin){
			// ½Ä
			for(int i = 0; i < 3; i++){
				bool f=false;
				char ch=field[0][i];
				if(ch!='+'){
					for(int j = 1; j < 3; j++){
						if(ch!=field[j][i]){
							f=true;
							break;
						}
					}
					// sè
					if(!f){
						fin=true;
						cout<<ch<<endl;
						break;
					}
				}
			}
			if(!fin){
				// ÈÈß
				char ch=field[0][0];
				if(ch!='+'&&field[1][1]==ch&&field[2][2]==ch){
					fin=true;
					cout<<ch<<endl;
				}
				else if(field[1][1]!='+'&&field[1][1]==field[2][0]&&field[2][0]==field[0][2]){
					fin=true;
					cout<<field[1][1]<<endl;
				}
			}
			else
				cout<<"NA"<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
string s[3];
while(cin>>s[0]){
if(s[0]=="0")break;
cin>>s[1]>>s[2];
if(s[0][0]!='+'&&s[0][0]==s[0][1]&&s[0][1]==s[0][2]){cout<<s[0][0]<<endl;continue;}
if(s[1][0]!='+'&&s[1][0]==s[1][1]&&s[1][1]==s[1][2]){cout<<s[1][0]<<endl;continue;}
if(s[2][0]!='+'&&s[2][0]==s[2][1]&&s[2][1]==s[2][2]){cout<<s[2][0]<<endl;continue;}
if(s[0][0]!='+'&&s[0][0]==s[1][0]&&s[1][0]==s[2][0]){cout<<s[0][0]<<endl;continue;}
if(s[0][1]!='+'&&s[0][1]==s[1][1]&&s[1][1]==s[2][1]){cout<<s[0][1]<<endl;continue;}
if(s[0][2]!='+'&&s[0][2]==s[1][2]&&s[1][2]==s[2][2]){cout<<s[0][2]<<endl;continue;}
if(s[0][0]!='+'&&s[0][0]==s[1][1]&&s[1][1]==s[2][2]){cout<<s[0][0]<<endl;continue;}
if(s[0][2]!='+'&&s[0][2]==s[1][1]&&s[1][1]==s[2][0]){cout<<s[0][2]<<endl;continue;}
cout<<"NA"<<endl;
}
return 0;
}

C++: #include <iostream>

void dwrite(int i){
	std::cout << i << std::endl;
}

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