#include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  int b,w;
  
  string str[3];
  int cnt = 0 ;
  while(getline(cin,str[cnt]),str[cnt]!="0"){
    if(cnt==2){
      if(str[0][0] == str[0][1] && str[0][1] == str[0][2])cout<<str[0][1];
      else if(str[1][0] == str[1][1] && str[1][1] == str[1][2])cout<<str[1][1];
      else if(str[2][0] == str[2][1] && str[2][1] == str[2][2])cout<<str[2][1];


      else if(str[0][0] == str[1][0] && str[1][0] == str[2][0])cout<<str[0][0];
      else if(str[0][1] == str[1][1] && str[1][1] == str[2][1])cout<<str[0][1];
      else if(str[0][2] == str[1][2] && str[1][2] == str[2][2])cout<<str[0][2];
      
      else cout<<"NA";
      cout<<endl;
      b = w = 0;
      cnt = -1;
    }
    cnt++;
  }
  return 0;
}