import java.util.*;

public class file {

    private static final Scanner sc = new Scanner(System.in);
    private static int final_count;
    private static char[][] arr;
    private static boolean[][] visited;

    private static void foo() {
        int x = sc.nextInt(), y = sc.nextInt();
        arr = new char[x][y];
        visited = new boolean[arr.length][arr[0].length];
        final_count = 0;
        for (int i = 0; i < x; i++) {
            String str = sc.next();
            for (int j = 0; j < y; j++) {
                arr[i][j] = str.charAt(j);
            }
        }
        int count = 0;
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                if (arr[i][j] == 'B') {
                    surround(i, j);
                }
                else if (arr[i][j] == 'G') {
                    count++;
                }
            }
        }
        dfs(x - 1, y - 1);
        if (count == final_count) System.out.println("Yes");
        else System.out.println("No");
    }

    public static void dfs(int a, int b) {
        if (visited[a][b] || arr[a][b] == '#' || arr[a][b] == 'B') return;
        else visited[a][b] = true;
        if (arr[a][b] == 'G') final_count++;
        if (a - 1 >= 0 && arr[a - 1][b] != 'B' && arr[a - 1][b] != '#') dfs(a - 1, b);
        if (a + 1 < arr.length && arr[a + 1][b] != 'B' && arr[a + 1][b] != '#') dfs(a + 1, b);
        if (b - 1 >= 0 && arr[a][b - 1] != 'B' && arr[a][b - 1] != '#') dfs(a, b - 1);
        if (b + 1 < arr[0].length && arr[a][b + 1] != 'B' && arr[a][b + 1] != '#') dfs(a, b + 1);
    }

    public static void surround(int a, int b) {

        if (a + 1 < arr.length) {
            if (arr[a + 1][b] != 'B' && arr[a + 1][b] != 'G') arr[a + 1][b] = '#';
            if (b - 1 >= 0 && arr[a][b - 1] != 'B' && arr[a][b - 1] != 'G') arr[a][b - 1] = '#';
            if (b + 1 < arr[0].length && arr[a][b + 1] != 'B' && arr[a][b + 1] != 'G') arr[a][b + 1] = '#';
        }
        if (a - 1 >= 0 && arr[a - 1][b] != 'B' && arr[a - 1][b] != 'G') arr[a - 1][b] = '#';
    }


    public static void main(String[] args) {
        int T = Integer.parseInt(sc.next());
        for (int i = 1; i <= T; i++) foo();
    }
}