import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	while (1) {
		string area[3];
    auto res = "NA";
    bool f;
    foreach (i; 0..3) {
      area[i] = readln.chomp;
      if (area[i] == "0") {
        f = 1;
        break;
      }
      if (area[i].count!(a => a == 'b') == 3) res = "b";
      if (area[i].count!(a => a == 'w') == 3) res = "w";
    }
    if (f) break;
    foreach (i; 0..3) {
      if (area[0][i] == area[1][i] && area[1][i] == area[2][i]) {
        if  (area[0][i] == 'w' || area[0][i] == 'b') {
          res = area[0][i].to!string;
        }
      }
    }
    if (area[0][0] == area[1][1] && area[1][1] == area[2][2] ||
      area[2][0] == area[1][1] && area[1][1] == area[0][2]) {
      if  (area[1][1] == 'w' || area[1][1] == 'b') {
        res = area[1][1].to!string;
      }
    }
    res.writeln;
	}
}