#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
char same(char c[3][3]) {
	char ret = '+';
	rep(i,3) {
		if(c[i][0] == c[i][1] && c[i][1] == c[i][2] && c[i][0] != '+') ret = c[i][0];
	}
	rep(i,3) {
		if(c[0][i] == c[1][i] && c[1][i] == c[2][i] && c[0][i] != '+') ret = c[0][i];
	}
	if(c[0][0] == c[1][1] && c[1][1] == c[2][2] && c[0][0] != '+') ret = c[0][0];
	if(c[2][0] == c[1][1] && c[1][1] == c[0][2] && c[2][0] != '+') ret = c[2][0];
	return ret;
}
int main(){
	char b[3][3];
	string s;
	while(cin >> s, s != "0") {
		rep(i,3) {
			b[0][i] = s[i];
		}
		rep2(i,1,3) {
			cin >> s;
			rep(j,3) {
				b[i][j]= s[j];
			}
		}
		if(same(b) == '+') cout << "NA" << endl;
		else cout << same(b) << endl;
	}
	return 0;
}