#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	string s;
	while(cin >> s)
	{
		if(s == "0") break;
	
		vector<string> v;
		v.push_back(s);

		rep(i,2)
		{
			string temp;
			cin >> temp;
			v.push_back(temp);
		}

		bool flag = true;

		rep(i,3)
		{
			if(v[i][0] == v[i][1] && v[i][1] == v[i][2])
			{
				if(v[i][0] == 'b' || v[i][0] == 'w')
				{
					cout << v[i][0] << endl;
					flag = false;
					break;
				}
			}

			if(v[0][i] == v[1][i] && v[1][i] == v[2][i])
			{
				if(v[0][i] == 'b' || v[0][i] == 'w')
				{
					cout << v[0][i] << endl;
					flag = false;
					break;
				}
			}
		}

		if(flag)
		{
			if(v[0][0] == v[1][1] && v[1][1] == v[2][2])
			{
				if(v[0][0] == 'b' || v[0][0] == 'w')
				{
					cout << v[0][0] << endl;
					flag = false;
				}
			}

			else if(v[2][0] == v[1][1] && v[1][1] == v[0][2])
			{
				if(v[2][0] == 'b' || v[2][0] == 'w')
				{
					cout << v[2][0] << endl;
					flag = false;
				}
			}
		}

		if(flag) cout << "NA" << endl;
	}
	return 0;
}