#include <bits/stdc++.h>
using namespace std;
int main() {
	string s[3];
	while (cin >> s[0]) {
		if (s[0] == "0")
			break;
		cin >> s[1] >> s[2];
		if (s[0][0] != '+' && s[0][0] == s[0][1] && s[0][1] == s[0][2]) {
			cout << s[0][0] << endl;
			continue;
		}
		if (s[1][0] != '+' && s[1][0] == s[1][1] && s[1][1] == s[1][2]) {
			cout << s[1][0] << endl;
			continue;
		}
		if (s[2][0] != '+' && s[2][0] == s[2][1] && s[2][1] == s[2][2]) {
			cout << s[2][0] << endl;
			continue;
		}
		if (s[0][0] != '+' && s[0][0] == s[1][0] && s[1][0] == s[2][0]) {
			cout << s[0][0] << endl;
			continue;
		}
		if (s[0][1] != '+' && s[0][1] == s[1][1] && s[1][1] == s[2][1]) {
			cout << s[0][1] << endl;
			continue;
		}
		if (s[0][2] != '+' && s[0][2] == s[1][2] && s[1][2] == s[2][2]) {
			cout << s[0][2] << endl;
			continue;
		}
		if (s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2]) {
			cout << s[0][0] << endl;
			continue;
		}
		if (s[0][2] != '+' && s[0][2] == s[1][1] && s[1][1] == s[2][0]) {
			cout << s[0][2] << endl;
			continue;
		}
		cout << "NA" << endl;
	}
	return 0;
}