#include<iostream>
using namespace std;

bool judge( char a, char b, char c )
{
    if( a == b && b == c && a != '+' )
        return true;
    return false;
}

int main()
{
    char c[3][3];

    while( cin >> c[0][0] )
    {
        if( c[0][0] == '0' )
            break;
        
        cin >> c[0][1] >> c[0][2];
        for( int i = 1; i < 3; i++ )
            for( int j = 0; j < 3; j++ )
                cin >> c[i][j];

        bool na = true, one = true;
        for( int i = 0; i < 3; i++ )
            if( judge( c[i][0], c[i][1], c[i][2] ) || judge( c[0][i], c[1][i], c[2][i] ) )
            {
                cout << c[i][i] << endl;
                na = false;
                one = false;
                break;
            }

        if( judge( c[0][0], c[1][1], c[2][2] ) || judge( c[0][2], c[1][1], c[2][0] ) && one )
        {
            cout << c[1][1] << endl;
            na = false;
        }
        if( na )
            cout << "NA" << endl;
    }
    return 0;
}
