import java.io.*;
import java.util.Arrays;

public class D2 { // TLE case 10

    static int[] dr = {1, 0, -1, 0};
    static int[] dc = {0, 1, 0, -1};
    static int[][] grid = new int[52][52]; //0: grid; 1: close; 2: end

    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            int testCnt = Integer.parseInt(br.readLine());
            Arrays.fill(grid[0], 1);
            for (int i = 0; i < testCnt; i++) {
                String[] line = br.readLine().split(" ");
                int rowCnt = Integer.parseInt(line[0]);
                int colCnt = Integer.parseInt(line[1]);
                //create boundaries:
                for (int j = 1; j <= rowCnt; j++) {
                    Arrays.fill(grid[j], 0);
                    grid[j][0] = 1;
                    grid[j][colCnt + 1] = 1;
                }
                Arrays.fill(grid[rowCnt + 1], 1);
                //scan in:
                int gCnt = 0;
                for (int j = 0; j < rowCnt; j++) {
                    String curRow = br.readLine();
                    for (int k = 0; k < colCnt; k++) {
                        char cur = curRow.charAt(k);
                        if (cur == '#') grid[j + 1][k + 1] = 1;
                        else if (cur == 'G') {
                            grid[j + 1][k + 1] = 2;
                            gCnt++;
                        }
                        else if (cur == 'B') {
                            dbug("<>. <> <> ", i, j, k);
                            for (int l = 0; l < 4; l++) {
                                dbug("<>. <> <> ", l, j + 1 + dr[l], k + 1 + dc[l]);
                                grid[j + 1 + dr[l]][k + 1 + dc[l]] = 1;
                            }
                        }
                    }
                }

                if (gCnt == 0) {
                    bw.write("Yes\n");
                    continue;
                }
                if (grid[rowCnt][colCnt] == 1) {
                    bw.write("No\n");
                    continue;
                }

                print(grid, rowCnt, colCnt);

                int endCnt = 0;
                int[][] q = new int[rowCnt * colCnt][2];
                boolean[][] visited = new boolean[rowCnt + 2][colCnt + 2];
                q[0][0] = rowCnt;
                q[0][1] = colCnt;
                int write = 1;
                visited[rowCnt][colCnt] = true;
                for (int read = 0; read < write; read++) {
                    int curRow = q[read][0];
                    int curCol = q[read][1];
                    dbug("<>) <> <> at <> <> ", read, q[read][0], q[read][1], curRow, curCol);

                    if (grid[curRow][curCol] == 2) endCnt++;

                    for (int j = 0; j < 4; j++) {
                        int newRow = curRow + dr[j];
                        int newCol = curCol + dc[j];
                        if (!visited[newRow][newCol] && grid[newRow][newCol] != 1) {
                            dbug("<>. <> <> <> ", j, write, newRow, newCol);
                            visited[newRow][newCol] = true;
                            q[write][0] = newRow;
                            q[write][1] = newCol;
                            write++;
                        }
                    }
                }

                if (i == 1) print(q, 0, 0);

                bw.write((endCnt == gCnt)? "Yes\n": "No\n");

                dbug("");
            }
            br.close();
            bw.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void dbug(String s, long ... a) { /*
        String[] line = s.split("<>");
        for (int i = 0; i < a.length; i++) {
            System.out.print(line[i] + a[i]);
        }
        System.out.println(line[a.length]); // */
    }

    public static void print(int[][] a, int rowCnt, int colCnt) { /*
        for (int i = 0; i <= rowCnt + 1; i++) {
            for (int j = 0; j <= colCnt + 1; j++) {
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println(); // */
    }
}