#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        vector<string> s(3);
        for(int i=0; i<3; ++i){
            cin >> s[i];
            if(s[i] == "0")
                return 0;
        }

        char win = ' ';
        for(int i=0; i<3; ++i){
            if(s[i][0] != '+' && s[i][0] == s[i][1] && s[i][1] == s[i][2])
                win = s[i][0];
            if(s[0][i] != '+' && s[0][i] == s[1][i] && s[1][i] == s[2][i])
                win = s[0][i];
        }
        if(s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2])
            win = s[0][0];
        if(s[2][0] != '+' && s[2][0] == s[1][1] && s[1][1] == s[0][2])
            win = s[2][0];

        if(win == ' ')
            cout << "NA" << endl;
        else
            cout << win << endl;
    }
}