#include <iostream>
using namespace std;
char field[3][3];

void check() {
	for (int i = 0; i < 3; ++i) {
		if (field[i][0] != '+' && field[i][0] == field[i][1]) {
			if (field[i][1] == field[i][2]) {
				cout << field[i][2] << endl; return;
			}
		}
	}
	for (int i = 0; i < 3; ++i) {
		if (field[0][i] != '+' && field[0][i] == field[1][i]) {
			if (field[1][i] == field[2][i]) {
				cout << field[2][i] << endl; return;
			}
		}
	}

	if (field[0][0] != '+' && field[0][0] == field[1][1] && field[1][1] == field[2][2]) {
		cout << field[0][0] << endl;  return;
	}
	
	if (field[0][2] != '+' && field[0][2] == field[1][1] && field[1][1] == field[2][0]) {
		cout << field[0][2] << endl; return;
	}
	cout << "NA" << endl;
	return;
}

int main() {

	while (cin >> field[0][0], field[0][0]-'0') {
		cin >> field[0][1] >> field[0][2];

		for (int i = 1; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				cin >> field[i][j];
			}
		}
		check();
	}

	return 0;
}