import java.util.Scanner;

public class Main {
    static final int[][] dir = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 }, };
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        turn:
        while (t-- > 0) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            char[][] maze = new char[n][];
            for (int i = 0; i < n; i++) {
                maze[i] = sc.next().toCharArray();
            }
            
            int cntG = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    switch (maze[i][j]) {
                        case 'B':
                            for (int[] d : dir) {
                                int r = i + d[0];
                                int c = j + d[1];
                                if (!inBound(r, c, n, m)) {
                                    continue;
                                }
                                switch (maze[r][c]) {
                                    case 'G':
                                        out(false);
                                        continue turn;
                                    case '.':
                                        maze[r][c] = '#';
                                        break;
                                    default:
                                }
                            }
                            break;
                        case 'G':
                            cntG++;
                            break;
                        default:
                    }
                }
            }
            
            boolean[][] visited = new boolean[n][m];
            int reachables = reachables(maze, n - 1, m - 1, visited);
            out(reachables == cntG);
        }
    }
    
    static int reachables(char[][] maze, int i, int j, boolean[][] visited) {
        int n = maze.length, m = maze[0].length;
        if (!inBound(i, j, n, m) || maze[i][j] == '#') {
            return 0;
        }
        if (visited[i][j]) {
            return 0;
        }
        
        int total = 0;
        if (maze[i][j] == 'G') {
            total++;
        }
        visited[i][j] = true;
        for (int[] d : dir) {
            int r = i + d[0];
            int c = j + d[1];
            total += reachables(maze, r, c, visited);
        }
        return total;
    }
    
    private static boolean inBound(int i, int j, int n, int m) {
        return inBound(i, 0, n) && inBound(j, 0, m);
    }
    
    private static boolean inBound(int i, int l, int r) {
        return i >= l && i < r;
    }
    
    static void out(boolean can) {
        System.out.println(can ? "Yes" : "No");
    }
    
}
