#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;

char a[3][3];
int main() {
	while (cin >> a[0][0], a[0][0] != 48) {
		rep(i, 3)rep(j, 3)if (i || j)cin >> a[i][j];
		rep(i, 3) {
			if (a[i][0] == a[i][1] && a[i][1] == a[i][2] && a[i][0] != '+') {
				cout << a[i][0] << endl;
				goto p;
			}
			if (a[0][i] == a[1][i] && a[1][i] == a[2][i] && a[0][i] != '+') {
				cout << a[0][i] << endl;
				goto p;
			}
		}
		if (a[0][0] == a[1][1] && a[1][1] == a[2][2] && a[0][0] != '+') {
			cout << a[0][0] << endl;
			goto p;
		}
		if (a[0][2] == a[1][1] && a[1][1] == a[2][0] && a[0][2] != '+') {
			cout << a[0][2] << endl;
			goto p;
		}
		puts("NA");
	p:;
	}
}