#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char ban[9];
  int hoge[9];
  int tmp[8][3]={{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
  while(true){
    int hatena = -1;
    cin >> ban[0];
    if(ban[0]=='0') break;
    for(int i=1;i<9;i++) cin >> ban[i];
    for(int i=0;i<9;i++) hoge[i] = (ban[i]=='b'?1:(ban[i]=='w'?-1:0));
    for(int i=0;i<8;i++){
      bool ok=false;
      int bw = 0;
      for(int j=0;j<3;j++)bw += hoge[tmp[i][j]];
      if(bw==-3){
	hatena = 1;
	break;
      }	else if(bw==3){
	hatena = 2;
	break;
      }
    }
    cout << (hatena==1?"w":(hatena==2?"b":"NA")) << endl;
  }
}