#include <iostream>

using namespace std;

int main() {
	char hyou[3][3];
	while (cin >> hyou[0][0]) {
		if (hyou[0][0] == '0') {
			break;
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i != 0 ||  j != 0) {
					cin >> hyou[i][j];
				}
			}
		}
		bool hantei = true;
		for (int i = 0; i < 3; i++) {
			if (hyou[i][0] != '+' && hyou[i][0] == hyou[i][1] && hyou[i][0] == hyou[i][2]) {
				cout << hyou[i][0] << endl;
				hantei = false;
				break;
			}
			if (hyou[0][i] != '+' && hyou[0][i] == hyou[1][i] && hyou[0][i] == hyou[2][i]) {
				cout << hyou[0][i] << endl;
				hantei = false;
				break;
			}
		}
		if (hantei) {
			if (hyou[0][0] != '+' && hyou[0][0] == hyou[1][1] && hyou[0][0] == hyou[2][2]) {
				cout << hyou[0][0] << endl;
				hantei = false;
			}
			if (hyou[0][2] != '+' && hyou[0][2] == hyou[1][1] && hyou[0][2] == hyou[2][0]) {
				cout << hyou[0][2] << endl;
				hantei = false;
			}
			if (hantei) {
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}