#include <string>
#include <iostream>
#include <vector>
using namespace std;

#define rep(i,b) for(int i=0; i<int(b); i++)
using namespace std;

void solve(vector<string> const& s){
    if(s[0][0]==s[0][1] && s[0][1]==s[0][2] && s[0][0] != '+'){
        cout << s[0][0] << endl;
    }
    else if(s[0][0]==s[1][0] && s[1][0]==s[2][0] && s[0][0] != '+'){
        cout << s[0][0] << endl;
    }
    else if(s[0][0]==s[1][1] && s[1][1]==s[2][2] && s[0][0] != '+'){
        cout << s[0][0] << endl;
    }
    else if(s[0][1]==s[1][1] && s[1][1]==s[2][1] && s[0][1] != '+'){
        cout << s[0][1] << endl;
    }
    else if(s[0][2]==s[1][2] && s[1][2]==s[2][2] && s[0][2] != '+'){
        cout << s[0][2] << endl;
    }
    else if(s[0][2]==s[1][1] && s[1][1]==s[2][0] && s[0][2] != '+'){
        cout << s[0][2] << endl;
    }
    else if(s[1][0]==s[1][1] && s[1][1]==s[1][2] && s[1][0] != '+'){
        cout << s[1][0] << endl;
    }
    else if(s[2][0]==s[2][1] && s[2][1]==s[2][2] && s[2][0] != '+'){
        cout << s[2][0] << endl;
    } else {
        cout<< "NA" << endl;
    }
}

int main(){
    while(1){
        vector<string> s(3);
        rep(i,3){
            if(cin >> s[i]) continue;
            return 0;
        }
        solve(s);
    }
}