#include<iostream>
#include<string>
using namespace std;

int mask[8]={0444,0222,0111,0700,070,07,0124,0421};
int create_mask(char c,char board[9]){
	int res=0;
	for(int i=0;i<9;i++){
		if(c==board[i])res |= 1<<i;
	}
	return res;
}
int main(){
	char board[9];
	int b,w;
	string win;
	while(cin>>board[0], board[0]!='0'){
		for(int i=1;i<9;i++)cin>>board[i];
		b = create_mask('b',board);
		w = create_mask('w',board);
		win = "NA";
		for(int i=0;i<8;i++){
			if((w&mask[i])==mask[i]){
				win="w";
				break;
			}
			else if((b&mask[i])==mask[i]){
				win="b";
				break;
			}
		}
		cout<<win<<endl;
	}
}