#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool winny(char c,string grid[]){
  REP(y,3){
    bool win = true;
    REP(x,3){
      if(grid[y][x]!=c) win = false;
    }
    if(win) return true;
  }
  REP(x,3){
    bool win = true;
    REP(y,3){
      if(grid[y][x]!=c) win = false;
    }
    if(win) return true;
  }
  bool win = true;
  REP(k,3){
    if(grid[k][k]!=c) win=false;
  }
  if(win) return true;
  win = true;
  REP(k,3){
    if(grid[k][2-k]!=c) win=false;
  }
  if(win) return true;

  return false;
}

int main(void){
  string line;
  while(cin>>line){
    if(line=="0") break;
    string grid[3];
    grid[0] = line;
    REP(i,2)cin>>grid[1+i];
    if(winny('b',grid)) cout<<"b"<<endl;
    else if (winny('w',grid)) cout<<"w"<<endl;
    else cout<<"NA"<<endl;
  }

  return 0;
}