#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string s[3];
	bool flg = false;
	cin >> s[0];
	if(s[0] == "0") break;
	cin >> s[1] >> s[2];
	REP(i,3)
	    if(s[i][0] == s[i][1] && s[i][0] == s[i][2]){
		if(s[i][0] == '+') continue;
		cout << s[i][0] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;
	REP(i,3)
	    if(s[0][i] == s[1][i] && s[0][i] == s[2][i]){
		if(s[0][i] == '+') continue;
		cout << s[0][i] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;

	if(s[0][0] == s[1][1] && s[0][0] == s[2][2]){
	    if(s[0][0] != '+'){
		cout << s[0][0] << endl;
		flg = true;
	    }
	}
	if(flg) continue;
	if(s[0][2] == s[1][1] && s[2][0] == s[1][1]){
	    if(s[0][2] != '+'){
		cout << s[0][2] << endl;
		flg = true;
	    }
	}
	if(flg) continue;
	cout << "NA" << endl;
    }
    return 0;
}