//38
#include<iostream>

using namespace std;

int main(){
  for(;;){
    char g[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	cin>>g[i][j];
	if(g[i][j]=='0')return 0;
      }
    }
    for(int i=0;i<3;i++){
      if(g[i][0]!='+'&&g[i][0]==g[i][1]&&g[i][0]==g[i][2]){
	cout<<g[i][0]<<endl;
	goto next;
      }
      if(g[0][i]!='+'&&g[0][i]==g[1][i]&&g[0][i]==g[2][i]){
	cout<<g[0][i]<<endl;
	goto next;
      }
    }
    if(g[1][1]!='+'){
      if((g[0][0]==g[1][1]&&g[2][2]==g[1][1])||(g[0][2]==g[1][1]&&g[2][0]==g[1][1])){
	cout<<g[1][1]<<endl;
	goto next;
      }
    }
    cout<<"NA"<<endl;
    continue;
  next:
    ;
  }
  return 0;
}