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")
		}
	}
}

Python: def f1(c, l):
    for i in range(3):
        if c*3 == l[i]:
            return 1
    return 0

def f2(c, l):
    for i in range(0, 7, 3):
        s = set(h[i:i+3])
        if c in s and len(s) == 1:
            return 1
    return 0

def f3(c, l):
    if c*3 == l[0]+l[4]+l[8]:
        return 1
    if c*3 == l[2]+l[4]+l[6]:
        return 1
    return 0

while True:
    try:
        w = [input() for _ in range(3)]
    except:
        break
    if f1('b', w):
        print('b')
        continue
    if f1('w', w):
        print('w')
        continue
    h = [w[j][i] for i in range(3) for j in range(3)]
    if f2('b', h):
        print('b')
        continue
    if f2('w', h):
        print('w')
        continue
    if f3('b', h):
        print('b')
        continue
    if f3('w' , h):
        print('w')
        continue
    print("NA")

Python: all_b = "bbb"
all_w = "www"
while True:
  r1 = input()
  if r1 == "0":
    break
  r2 = input()
  r3 = input()
  cands = [r1, r2, r3]
  for i in range(3):
    col = r1[i] + r2[i] + r3[i]
    cands.append(col)
  cands.append(r1[0] + r2[1] + r3[2])
  cands.append(r1[2] + r2[1] + r3[0])
  for cand in cands:
    if cand == all_b:
      print("b")
      break
    elif cand == all_w:
      print("w")
      break
  else:
    print("NA")

Python: while True:

    input_data1 = input()

    if input_data1 == "0":
        break

    input_data2 = input()
    input_data3 = input()

    output = "NA"

    if input_data1[0] != "+" and input_data1[0] == input_data1[1] == input_data1[2]:
        output = input_data1[0]
    elif input_data2[0] != "+" and input_data2[0] == input_data2[1] == input_data2[2]:
        output = input_data2[0]
    elif input_data3[0] != "+" and input_data3[0] == input_data3[1] == input_data3[2]:
        output = input_data3[0]

    elif input_data1[0] != "+" and input_data1[0] == input_data2[0] == input_data3[0]:
        output = input_data1[0]
    elif input_data1[1] != "+" and input_data1[1] == input_data2[1] == input_data3[1]:
        output = input_data1[1]
    elif input_data1[2] != "+" and input_data1[2] == input_data2[2] == input_data3[2]:
        output = input_data1[2]

    elif input_data1[0] != "+" and input_data1[0] == input_data2[1] == input_data3[2]:
        output = input_data1[0]
    elif input_data1[2] != "+" and input_data1[2] == input_data2[1] == input_data3[0]:
        output = input_data1[2]

    print(output)

Python: def f(a):
    for x in ['b','w']:
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'NA'

while 1:
    a=input()
    if a=='0':break
    a+=input()+input()
    print(f(list(a)))

Python: def f(a):
    for x in ['b','w']:
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'NA'

while 1:
    a=list(input())
    if len(a)==1:break
    a+=list(input())+list(input())
    print(f(a))

Python: def f(a):
    for x in 'bw':
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'NA'

while 1:
    a=input()
    if a =='0':break
    print(f(a+input()+input()))

Python: while True:

    input_data1 = input()

    if input_data1 == "0":
        break

    input_data2 = input()
    input_data3 = input()

    output = "NA"

    if input_data1[0] == input_data1[1] == input_data1[2]:
        output = input_data1[0]
    elif input_data2[0] == input_data2[1] == input_data2[2]:
        output = input_data2[0]
    elif input_data3[0] == input_data3[1] == input_data3[2]:
        output = input_data3[0]

    elif input_data1[0] == input_data2[0] == input_data3[0]:
        output = input_data1[0]
    elif input_data1[1] == input_data2[1] == input_data3[1]:
        output = input_data1[1]
    elif input_data1[2] == input_data2[2] == input_data3[2]:
        output = input_data1[2]

    elif input_data1[0] == input_data2[1] == input_data3[2]:
        output = input_data1[0]
    elif input_data1[2] == input_data2[1] == input_data3[0]:
        output = input_data1[2]

    print(output)

Python: import sys
while True:
    Fu = []
    boa = input()
    if boa == "0":
        break
    Fu.append(list(boa))
    for i in range(2):
        boa = list(input())
        Fu.append(boa)
    for i in range(3):
        if Fu[i][0] == Fu[i][1] == Fu[i][2]:
            print(Fu[i][0])
            sys.exit()

        if Fu[0][i] == Fu[1][i] == Fu[2][i]:
            print(Fu[0][i])
            sys.exit()
    if Fu[0][0] == Fu[1][1] == Fu[2][2]:
        print(Fu[0][0])
        sys.exit()
    if Fu[0][2] == Fu[1][1] == Fu[2][0]:
        print(Fu[1][1])
        sys.exit()
    print("NA")

Python: while 1:
    board = []
    n = list(input())
    if n[0] == "0":
        break

    board.append(n)
    for _ in range(2):
        n = list(input())
        board.append(n)

    ans = "NA"
    for i in range(3):
        if board[i][0] == board[i][1] == board[i][2] and board[i][0] != "+":
            ans = board[i][0]
        elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != "+":
            ans = board[0][i]

    if board[0][0] == board[1][1] == board[2][2] and board[0][0] != "+":
        ans = board[0][0]
    elif board[2][0] == board[1][1] == board[0][2] and board[2][0] != "+":
        ans = board[1][1]

    print(ans)

Python: def f(a):
    for x in ['b','w']:
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'NA'

while 1:
    a=input()
    if a=='0':break
    print(f(a+input()+input()))

Python: while True:
    L = input()
    if L == "0":
        break

    table = [["+" for i in range(3)] for j in range(3)]
    for i in range(3):
        table[0][i] = L[i]

    L = input()
    for i in range(3):
        table[1][i] = L[i]

    L = input()
    for i in range(3):
        table[2][i] = L[i]

    ans = "NA"
    for i in range(3):
        if table[0][i] == table[1][i] and table[1][i] == table[2][i] and table[0][i] != "+":
            ans = table[0][i]
            break
        if table[i][0] == table[i][1] and table[i][1] == table[i][2] and table[i][0] != "+":
            ans = table[i][0]
            break
    if table[0][0] == table[1][1] and table[1][1] == table[2][2] and table[0][0] != "+":
        ans = table[0][0]
    if table[2][0] == table[1][1] and table[1][1] == table[0][2] and table[2][0] != "+":
        ans = table[2][0]
    print(ans)