#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	while (1) {
		string a;
		cin >> a;
		if (a == "0")break;
		string b, c;
		cin >> b >> c;
		a += b + c;
		if (a[4] != '+' && (a[0] == a[4] && a[4] == a[8] || a[1] == a[4] && a[4] == a[7] || a[2] == a[4] && a[4] == a[6] || a[3] == a[4] && a[4] == a[5]))cout << a[4] << endl;
		else 	if (a[0] != '+' && (a[0] == a[1] && a[1] == a[2] || a[0] == a[3] && a[3] == a[6]))cout << a[0] << endl;
		else 	if (a[8] != '+' && (a[6] == a[7] && a[7] == a[8] || a[2] == a[5] && a[5] == a[8]))cout << a[8] << endl;
		else cout << "NA" << endl;
	}
}