#include <iostream>
#include <string>

#define BLACK 'b'
#define WHITE 'w'
#define SPACE '+'

using namespace std;


char isWin(string data[3]) {
  char temp;
  temp = data[0][0];
  if(temp != SPACE && data[1][1] == temp && data[2][2] == temp) return temp;
  temp = data[2][0];
  if(temp != SPACE && data[1][1] == temp && data[0][3] == temp) return temp;

  for(int i = 0; i < 3; i++) {
    temp = data[i][0];
    if(temp == SPACE) continue;
    bool flag = true;
    for(int j = 0; j < 3; j++) {
      if(data[i][j] != temp) {
	 flag = false;
	 break;
      }
    }
    if(flag) {
      return temp;
    }
  }

  for(int i = 0; i < 3; i++) {
    temp = data[0][i];
    if(temp == SPACE) continue;
    bool flag = true;
    for(int j = 0; j < 3; j++) {
      if(data[j][i] != temp) {
	 flag = false;
	 break;
      }
    }
    if(flag) {
      return temp;
    }
  }

  return SPACE;
}

int main() {
  while(1) {
    string data[3];
    getline(cin, data[0]);
    if(data[0] == "0") break;
    for(int i = 1; i < 3; i++) {
      getline(cin, data[i]);
    }

    char temp = isWin(data);
    if(temp == SPACE) {
      cout << "NA" << endl;
    } else {
      cout << temp << endl;
    }
  }
  return 0;
}