#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char board[4][4];
int main(){
	string str;
	while(cin>>str){
		bool flag=false;
		if(str=="0")break;
		board[0][0]=str[0];
		board[0][1]=str[1];
		board[0][2]=str[2];
		for(int i =1;i <3;i++){
			for(int j =0;j <3;j++){
				cin>>board[i][j];
			}
		}
		for(int i =0;i <3;i++){
			if((board[i][0]=='b'||board[i][0]=='w')&&
			   !flag&&board[i][0]==board[i][1]&&board[i][1]==board[i][2]){
				cout <<board[i][0]<<endl;
				flag =true;
				break;
			}
		}
		if(flag)continue;
		for(int j =0;j <3;j++){
			if((board[0][j]=='b'||board[0][j]=='w')&&
			   !flag&&board[0][j]==board[1][j]&&board[1][j]==board[2][j]){
				cout <<board[0][j]<<endl;
				flag =true;
				break;
			}
		}
		if(flag)continue;
		if((board[0][0]=='b'||board[0][0]=='w')
		   &&board[0][0]==board[1][1]&&board[1][1]==board[2][2]){
			cout <<board[0][0]<<endl;
			flag=true;
			break;
		}
		if(flag)continue;
		if((board[0][2]=='b'||board[0][2]=='w')
		   &&board[0][2]==board[1][1]&&board[0][2]==board[2][0]){
			cout <<board[0][2]<<endl;
			flag =true;
			break;
		}
		if(!flag)cout <<"NA"<<endl;
	}
	return 0;
}