#include <iostream>

int main()
{
	char board[3][3];
	while (true) {
		std::cin >> board[0][0];
		if (board[0][0] == '0') break;
		std::cin >> board[0][1] >> board[0][2];
		std::cin >> board[1][0] >> board[1][1] >> board[1][2];
		std::cin >> board[2][0] >> board[2][1] >> board[2][2];
		char c;
		bool isNA = true;
		// vertical
		for (int j=0; j<3; j++) {
			c = board[0][j];
			if (c == '+') continue;
			if (board[1][j] == c && board[2][j] == c) {
				std::cout << c << std::endl;
				isNA = false; break;
			}
		}
		// horizontal
		if (isNA) {
			for (int i=0; i<3; i++) {
				c = board[i][0];
				if (c == '+') continue;
				if (board[i][1] == c && board[i][2] == c) {
					std::cout << c << std::endl;
					isNA = false; break;
				}
			}
		}
		// diagonal
		if (isNA) {
			c = board[1][1];
			if (c != '+') {
				if (board[0][0] == c && c == board[2][2]) {
					std::cout << c << std::endl;
					isNA = false;
				}
				else if (board[2][0] == c && c == board[0][2]) {
					std::cout << c << std::endl;
					isNA = false;
				}
			}
		}
		if (isNA) std::cout << "NA" << std::endl;
	}
	return 0;
}

