#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s[3];

	while (cin >> s[0], s[0] != "0")
	{
		cin >> s[1] >> s[2];
	
		if (s[0][0] == s[0][1] && s[0][1] == s[0][2] && s[0][0] != '+')
		{
			cout << s[0][0] << endl;
		}
		else if (s[1][0] == s[1][1] && s[1][1] == s[1][2] && s[1][0] != '+')
		{
			cout << s[1][0] << endl;
		}
		else if (s[2][0] == s[2][1] && s[2][1] == s[2][2] && s[2][0] != '+')
		{
			cout << s[2][0] << endl;
		}
		else if (s[0][0] == s[1][0] && s[1][0] == s[2][0] && s[0][0] != '+')
		{
			cout << s[0][0] << endl;
		}
		else if (s[0][1] == s[1][1] && s[1][1] == s[2][1] && s[0][1] != '+')
		{
			cout << s[0][1] << endl;
		}
		else if (s[0][2] == s[1][2] && s[1][2] == s[2][2] && s[0][2] != '+')
		{
			cout << s[0][2] << endl;
		}
		else if (s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[0][0] != '+')
		{
			cout << s[0][0] << endl;
		}
		else if (s[0][2] == s[1][1] && s[1][1] == s[2][0] && s[0][2] != '+')
		{
			cout << s[0][2] << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}