#include <iostream>
#include <cstdio>
using namespace std;
 
int main(){
 
  int i,j;
  char g[3][3];
  char win;
   
  while(1){
     
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
    cin >> g[i][j];
    if(g[0][0]=='0') return 0;
    if(g[i][j]=='+') g[i][j]=(j+1)*(i+1);
      }
    }
   
    for(i=0;i<3;i++){
      if(g[i][0]==g[i][1] && g[i][0]==g[i][2]){
    win = g[i][0];
    break;
      }else if(g[0][i]==g[1][i] && g[0][i]==g[2][i]){
    win = g[0][i];
    break;
      }else if(g[0][0]==g[1][1] && g[0][0]==g[2][2]){
    win = g[0][0];
    break;
      }else if(g[0][2]==g[1][1] && g[0][2]==g[2][0]){
    win = g[0][2];
    break;
      }
       
    }
     
    if(i!=3) printf("%c\n",win);
    else puts("NA");
 
  }
 
    return 0;
} 