#include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<algorithm>
#include<cstring>
#include<vector>
#include<climits>
#include<map>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define INF (2<<25)
typedef pair<int,int> pii;
typedef vector<int> vi;

int main()
{
	while(true)
	{
		string a[3];
		cin>>a[0];
		if(a[0]=="0")break;
		cin>>a[1]>>a[2];
		bool isdraw=true;
		bool end=false;
		FOR(i,3)
		{
			bool equal[2]={1,1};
			if(end)break;
			FOR(j,3)
			{
				if(a[i][j]!=a[i][0])equal[0]=false;
				if(a[j][i]!=a[0][i])equal[1]=false;
			}
			FOR(j,2)
			{
				if(equal[j]&&a[(j?0:i)][j?i:0]!='+')
				{
					isdraw=false;
					cout<<a[(j?0:i)][j?i:0]<<endl;
					end=true;
					break;
				}
			}
		}
		bool equal[2]={1,1};
		FOR(i,3)
		{
			if(a[i][i]!=a[0][0])equal[0]=false;
			if(a[i][2-i]!=a[0][2])equal[1]=false;
		}
		FOR(j,2)
		{
			if(end)break;
			if(equal[j]&&a[(j?0:0)][j?2:0]!='+')
			{
				isdraw=false;
				cout<<a[(j?0:0)][j?2:0]<<endl;
				end=true;
				break;
			}
		}
		if(isdraw)cout<<"NA"<<endl;
	}
}