#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s[3];
  while (cin >> s[0], s[0] != "0") {
    cin >> s[1] >> s[2];
    string ans = "NA";
    for (int i = 0; i < 3; i++) {
      if (s[i][0] != '+' && s[i][0] == s[i][1] && s[i][1] == s[i][2]) {
        ans = string(1, s[i][0]);
      }
    }
    for (int i = 0; i < 3; i++) {
      if (s[0][i] != '+' && s[0][i] == s[1][i] && s[1][i] == s[2][i]) {
        ans = string(1, s[0][i]);
      }
    }
    if (s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2]) {
      ans = string(1, s[0][0]);
    }
    if (s[0][2] != '+' && s[0][2] == s[1][1] && s[1][1] == s[2][0]) {
      ans = string(1, s[0][2]);
    }
    cout << ans << endl;
  }

  return 0;
}
