#include<iostream>
#include<string>
using namespace std;
int main() {
	string s1, s2, s3;
	while (cin >> s1){
		if (s1 == "0")return 0;
		cin >> s2 >> s3;
		if (s1[0] != '+') {
			if (s1[0] == s1[1] && s1[0] == s1[2]) { cout << s1[0]; goto heaven; }
			else if (s1[0] == s2[1] && s1[0] == s3[2]) { cout << s1[0]; goto heaven; }
			else if (s1[0] == s2[0] && s1[0] == s3[0]) { cout << s1[0]; goto heaven; }
		}
		if (s1[1] != '+') {
			if (s1[1] == s2[1] && s1[1] == s3[1]) { cout << s1[1]; goto heaven; }
		}
		if (s1[2] != '+') {
			if (s1[2] == s2[1] && s1[2] == s3[0]) { cout << s1[2]; goto heaven; }
			else if (s1[2] == s2[2] && s1[2] == s3[2]) { cout << s1[2]; goto heaven; }
		}
		if (s2[0] != '+') {
			if (s2[0] == s2[1] && s2[0] == s2[2]) { cout << s2[0]; goto heaven; }
		}
		if (s3[0] != '+') {
			if (s3[0] == s3[1] && s3[0] == s3[2]) { cout << s3[0]; goto heaven; }
		}
		cout << "NA";
	heaven:cout << endl;
	}
}
