#include <iostream>

using namespace std;

int main(int argc, char **)
{
	int f;
	char a[3][4];
	
	while(scanf("%s", a[0])!=EOF){
		if(a[0][0] == '0'){
			break;
		}
		f = 0;
		scanf("%s", a[1]);
		scanf("%s", a[2]);
		for(int i = 0; i < 3; i++){
			if(a[0][i] == a[1][i] && a[0][i] == a[2][i] && (a[0][i] == 'w' || a[0][i] == 'b')){
				cout << a[0][0] << endl;
				f = 1;
				break;
			}
		}
		if(f == 0){
			if(a[0][0] == a[1][1] && a[0][0] == a[2][2] && (a[0][0] == 'w' || a[0][0] == 'b')){
				cout << a[0][0] << endl;
			} else if(a[0][2] == a[1][1] && a[0][2] == a[2][0] && (a[1][1] == 'w' || a[1][1] == 'b')){
				cout << a[1][1] << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
}