import java.util.Scanner;

public class SolveTheMaze {
    private static final Scanner in = new Scanner(System.in, "UTF-8");
    private static boolean[][] visited;
    private static int[][] maze;
    private static boolean reachedBad, changed;

    public static void main(String[] args) {
        int t = in.nextInt();
        while (t-- > 0) {
            reachedBad = false;
            changed = false;
            int n = in.nextInt(), m = in.nextInt();
            maze = new int[n][m];
            boolean thereIsGood = false, thereIsBad = false;
            int goodCount = 0;
            for (int i = 0; i < n; i++) {
                String row = in.next();
                for (int j = 0; j < m; j++) {
                    char type = row.charAt(j);
                    if (type == '#') maze[i][j] = 2;
                    if (type == '.') maze[i][j] = 0;
                    if (type == 'G') {
                        maze[i][j] = 1;
                        thereIsGood = true;
                        goodCount++;
                    }
                    if (type == 'B') {
                        maze[i][j] = -1;
                        thereIsBad = true;
                    }
                }
            }
            if (!thereIsGood) {
                System.out.println("Yes");
                continue;
            }
            visited = new boolean[n][m];
            int reachable = countReachable(n - 1, m - 1);
            if (reachable == goodCount && !thereIsBad) System.out.println("Yes");
            else if (reachable < goodCount) System.out.println("No");
            else {
                visited = new boolean[n][m];
                seenBad(n - 1, m - 1, n - 1, m - 1);
                while (reachedBad) {
                    if (!changed) break;
                    reachedBad = false;
                    changed = false;
                    visited = new boolean[n][m];
                    seenBad(n - 1, m - 1, n - 1, m - 1);
                }
                System.out.println(reachedBad ? "No" : "Yes");
            }
        }
    }

    private static int countReachable(int row, int col) {
        if (row < 0 || row >= maze.length || col < 0 || col >= maze[0].length
                || visited[row][col] || maze[row][col] == 2) return 0;
        visited[row][col] = true;
        return countReachable(row - 1, col) + countReachable(row, col - 1) + countReachable(row + 1, col) + countReachable(row, col + 1) + (maze[row][col] == 1 ? 1 : 0);
    }

    private static void seenBad(int row, int col, int row_of_amenable, int col_of_amenable) {
        if (row < 0 || row >= maze.length || col < 0 || col >= maze[0].length
                || maze[row][col] == 2) return;
        if (maze[row][col] == -1) {
            if (row_of_amenable == maze.length - 1 && col_of_amenable == maze[0].length - 1) {
                reachedBad = true;
            } else {
                maze[row_of_amenable][col_of_amenable] = 2;
                changed = true;
            }
            return;
        }
        if (maze[row][col] == 1) {
            row_of_amenable = maze.length - 1;
            col_of_amenable = maze[0].length - 1;
        }
        if (maze[row][col] == 0) {
            row_of_amenable = row;
            col_of_amenable = col;
        }
        if (!visited[row][col]) {
            visited[row][col] = true;
            seenBad(row - 1, col, row_of_amenable, col_of_amenable);
            seenBad(row + 1, col, row_of_amenable, col_of_amenable);
            seenBad(row, col - 1, row_of_amenable, col_of_amenable);
            seenBad(row, col + 1, row_of_amenable, col_of_amenable);
        }
    }
}
