fun main(args:Array<String>?): Unit {
    while(true){
        val l = readLine()!!.trim()
        if (l == "0") return
        val state = List(2){readLine()!!.trim()}.reversed() + l
        println(listOf('w', 'b').find{c ->
            (0 until 3).any{x -> (0 until 3).all{y -> state[y][x] == c} || (0 until 3).all{y -> state[x][y] == c}} ||
                    (state[1][1] == c && ((state[0][0] == c && state[2][2] == c) || (state[0][2] == c && state[2][0] == c)))
        } ?: "NA")
    }
}
