#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    string r[3];
    int i;
    while(cin>>r[0]&&r[0]!="0"){
        int ch=0;
        for(i=1;i<3;i++) cin>>r[i];
        for(i=0;i<3;i++){
            if(r[i][0]==r[i][1]
            &&r[i][1]==r[i][2]
            &&r[i][0]!='+'){
                cout<<r[i][0]<<endl;
                ch++;
            }
            if(r[0][i]==r[1][i]
            &&r[1][i]==r[2][i]
            &&r[0][i]!='+'){
                cout<<r[0][i]<<endl;
                ch++;
            }
        }
        if(ch) continue;
        if(r[0][0]==r[1][1]
        &&r[1][1]==r[2][2]
        &&r[0][0]!='+'){
            cout<<r[0][0]<<endl;
            continue;
        }
        if(r[0][2]==r[1][1]
        &&r[1][1]==r[2][0]
        &&r[2][0]!='+'){
            cout<<r[2][0]<<endl;
            continue;
        }
        cout<<"NA"<<endl;
    }
    return 0;
}
