package com.algorithm.test; import java.util.ArrayDeque; import java.util.Scanner; public class DfsAndBfs { private static final int[][] dir = { {,}, {,-}, {,-}, {,}, {,}, {-,-}, {-,}, {-,}, }; private static int[][] vis; private static char[][] map…