#include <iostream>
using namespace std;

int main()
{
	char field[3][3];
	while(true){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				cin >> field[i][j];
				if(field[i][j] == '0')
					return 0;
			}
		}
		bool flag = false;
		for(int i=0;i<3;i++){
			if(field[i][1] == field[i][0] && field[i][1] == field[i][2] && field[i][1] != '+'){
				cout << field[i][1] << endl;
				flag = true;
				break;
			}
			if(field[1][i] == field[0][i] && field[1][i] == field[2][i] && field[i][1] != '+'){
				cout << field[1][i] << endl;
				flag = true;
				break;
			}
		}
		if(flag)
			continue;
		if((field[1][1] == field[0][0] && field[1][1] == field[2][2]) || (field[1][1] == field[2][0] && field[1][1] == field[0][2]) && field[1][1] != '+'){
			cout << field[1][1] << endl;
			continue;
		}
		cout << "NA" << endl;
	}
	return 0;
}