#include <iostream>
using namespace std;

char board[8][8] = {{'+'}};
string ans = "NA";

void winp(char c, int x, int y){
    if (board[x][y] == c && board[x+1][y] == c && board[x+2][y] == c) ans = c;
    if (board[x][y] == c && board[x+1][y+1] == c && board[x+2][y+2] == c) ans = c;
    if (board[x][y] == c && board[x][y+1] == c && board[x+2][y+2] == c) ans = c;
}

int main(){
    while (1){
	bool end = false;
	for (int i = 0; i < 3 && !end; i++){
	    for (int j = 0; j < 3 && !end; j++){
		cin >> board[i][j];
		if (board[0][0] == '0') end = true;
	    }
	}
	if (end) break;
	ans = "NA";
	for (int i = 0; i < 3; i++)
	    for (int j = 0; j < 3; j++)
		if (board[i][j] == 'b') winp('b', i, j);
		else if (board[i][j] == 'w') winp('w', i, j);
	
	cout << ans << endl;
    }
}