#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	while (cin >> a&&a != "0") {
		char b[3][3];
		for (int i = 0; i < 3; i++)
			b[0][i] = a[i];
		for (int i = 1; i < 3; i++) {
			cin >> a;
			for (int j = 0; j < 3; j++) 
				b[i][j] = a[j];
		}
		string e;
		for (int i = 0; i < 3; i++) {
			bool c = true;
			char d = b[i][0];
			for (int j = 1; j < 3; j++) {
				if (b[i][j] != d||d=='+') 
					c = false;
			}
			if (c) {
				e = d;
				goto stop;
			}
		}
		for (int i = 0; i < 3; i++) {
			bool c = true;
			char d = b[0][i];
			for (int j = 1; j < 3; j++) {
				if (b[j][i] != d||d=='+')
					c = false;
			}
			if (c) {
				e = d;
				goto stop;
			}
		}
		if (b[0][0] == b[1][1] && b[1][1] == b[2][2]&&b[1][1]!='+') {
			e = b[0][0];
			goto stop;
		}
		if (b[0][2] == b[1][1] && b[1][1] == b[2][0]&&b[1][1]!='+') {
			e = b[1][1];
			goto stop;
		}
		e = "NA";
	stop:;
		cout << e << endl;
	}
}