#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	vector<string> s(3, "");
	string ans;
	while (1) {
		cin >> s[0] >> s[1] >> s[2];
		if (cin.eof())break;
		ans = "NA";
		for (int i = 0; i < 3; i++) {
			if ((s[i][0] != '+'&&s[i][0] == s[i][1] && s[i][1] == s[i][2])) {
				ans = s[i][0];
				break;
			}
			if ((s[0][i] != '+'&&s[0][i] == s[1][i] && s[1][i] == s[2][i])) {
				ans = s[0][i];
				break;
			}
		}
		if (s[1][1] != '+') {
			if ((s[1][1] == s[0][2] && s[1][1] == s[2][0]) || (s[1][1] == s[0][0] && s[1][1] == s[2][2])) {
				ans = s[1][1];
			}
		}
		cout << ans << endl;
	}
}