import java.io.*;
import java.util.StringTokenizer;

public class SolveTheMaze {

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int t = fs.nextInt();

        for (int i = 0; i < t; ++i) {
            int n = fs.nextInt();
            int m = fs.nextInt();

            int totalGoodGuys = 0;
            char[][] maze = new char[n][m];
            for (int j = 0; j < n; ++j) {
                String s = fs.nextToken();
                for (int k = 0; k < m; ++k) {
                    maze[j][k] = s.charAt(k);
                    if (maze[j][k] == 'G') {
                        totalGoodGuys++;
                    }
                }
            }

            dfs(maze);

//            for (int j = 0; j < n; ++j) {
//                for (int k = 0; k < m; ++k) {
//                    System.out.print(maze[j][k]);
//                }
//                System.out.println();
//            }
//            System.out.println("----");

            boolean result = canReachBadGuy(maze, new boolean[n][m], n - 1, m - 1);
            int[] goodGuys = new int[1];
            reachGoodGuys(maze, new boolean[n][m], n - 1, m - 1, goodGuys);
            System.out.println(result && goodGuys[0] == totalGoodGuys? "Yes": "No");

        }

    }

    private static void reachGoodGuys(char[][] maze, boolean[][] visited, int sx, int sy, int[] cnt) {
        if (visited[sx][sy] || maze[sx][sy] == '#') {
            return;
        }

        if (maze[sx][sy] == 'G') {
            cnt[0]++;
        }

        visited[sx][sy] = true;
        if (sx > 0) {
            reachGoodGuys(maze, visited, sx - 1, sy, cnt);
        }
        if (sy > 0) {
            reachGoodGuys(maze, visited, sx, sy - 1, cnt);
        }
        if (sx < maze.length - 1) {
            reachGoodGuys(maze, visited, sx + 1, sy, cnt);
        }
        if (sy < maze[0].length - 1) {
            reachGoodGuys(maze, visited, sx, sy + 1, cnt);
        }
    }

    private static boolean canReachBadGuy(char[][] maze, boolean[][] visited, int sx, int sy) {
//        System.out.println(maze.length + " " + maze[0].length);
//        System.out.println(sx + ", " + sy);
        if (visited[sx][sy] || maze[sx][sy] == '#') {
            return true;
        }

        if (maze[sx][sy] == 'B') {
            return false;
        }

        visited[sx][sy] = true;
        boolean res = true;
        if (sx > 0) {
            res = res && canReachBadGuy(maze, visited, sx - 1, sy);
        }
        if (sy > 0) {
            res = res && canReachBadGuy(maze, visited, sx, sy - 1);
        }
        if (sx < maze.length - 1) {
            res = res && canReachBadGuy(maze, visited, sx + 1, sy);
        }
        if (sy < maze[0].length - 1) {
            res = res && canReachBadGuy(maze, visited, sx, sy + 1);
        }
        return res;
    }

    private static void dfs(char[][] maze) {
        for (int j = 0; j < maze.length; ++j) {
            for (int k = 0; k < maze[0].length; ++k) {
                if (maze[j][k] == 'B') {
                    if (j > 0 && maze[j - 1][k] == '.') {
                        maze[j - 1][k] = '#';
                    }
                    if (j < maze.length - 1 && maze[j + 1][k] == '.') {
                        maze[j + 1][k] = '#';
                    }
                    if (k > 0 && maze[j][k - 1] == '.') {
                        maze[j][k - 1] = '#';
                    }
                    if (k < maze[0].length - 1 && maze[j][k + 1] == '.') {
                        maze[j][k + 1] = '#';
                    }
                }
            }
        }
    }
}
