#include <iostream>
using namespace std;

int main() {
  string str[3];
  while(1) {

    for(int i=0;i<3;i++) {
      getline(cin,str[i]);
      if(cin.eof()) return 0;
      //      cout << str[i] << endl;
    }

    bool r = false;
    for(int i=0;i<3;i++) { //yoko
      if(str[i][0] == str[i][1] && str[i][1] == str[i][2] && str[i][0] != '+') {
        cout << str[i][0] << endl;
        r = true;
        break;
      }
    }

    if(r) continue;

    for(int i=0;i<3;i++) { //tate
      if(str[0][i] == str[1][i] && str[1][i] == str[2][i] && str[0][i] != '+') {
        cout << str[0][i] << endl;
        r = true;
        break;
      }
    }

    if(r) continue;

    if(str[0][0] == str[1][1] && str[1][1] == str[2][2] && str[0][0] != '+') {  //naname
      cout << str[0][0] << endl;
      continue;
    }

    if(str[0][2] == str[1][1] && str[1][1] == str[2][0] && str[0][2] != '+') {  //naname
      cout << str[0][2] << endl;
      continue;
    }

    cout << "NA" << endl;
    continue;

  }
}