#include<iostream>
#include<string>

using namespace std;

int main(){
  int i, j;
  string c[3];
  char win;

  while(1){
    for(i=0; i<3; ++i){
      cin >> c[i];
      if(c[0] == "0") break;
    }
    if(c[0] == "0") break;

    win = '0';

    for(i=0; i<3; i++){
      if(c[i][0] == c[i][1] && c[i][0] == c[i][2] && c[i][0] != '+')
	win = c[i][0];
      if(c[0][i] == c[1][i] && c[0][i] == c[2][i] && c[0][i] != '+')
	win = c[0][i];
    }

    if(c[0][0] == c[1][1] && c[0][0] == c[2][2] && c[0][0] != '+')
      win = c[0][0];
    if(c[0][2] == c[1][1] && c[0][2] == c[2][0] && c[0][2] != '+')
      win = c[0][2];


    if(win == '0')
      cout << "NA" << endl;
    else
      cout << win << endl;
  }

  return 0;
}