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

string s[9];
int dx[] = {0,0,1,-1,1,1-1,-1};
int dy[] = {1,-1,0,0,-1,1,-1,1};
int k;

bool solve(char c, int p, int y, int x){
  if(y < 0 || x < 0 || y == 3 || x == 3) return false;
  if(c != s[y][x] || c == '+') return false;
  if(p == 3) return true;
  solve(c, p+1, y+dy[k], x+dx[k]);
}

int main(){

  while(true){
    cin >> s[0];
    if(s[0] == "0") break;
    cin >> s[1] >> s[2];

    char c = '@';
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	for(k=0;k<8;k++) if(solve(s[i][j], 1, i, j)) c = s[i][j];
      }
    }
    
    if(c == '@') cout << "NA" << endl;
    else cout << c << endl;
    
  }
}