import java.util.Arrays;
import java.util.Scanner;

// https://codeforces.com/contest/1365/problem/D
public class SolveMaze {
    static char[][] maze;
    static int[][] dist;
    static int[] a = {-1, 1};
    static int n, m;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int T = scan.nextInt(); scan.nextLine();
        while (T-- > 0) {
            n = scan.nextInt(); m = scan.nextInt(); scan.nextLine();
            maze = new char[n][m];
            dist = new int[n][m];
            for (int i = 0; i < n; i++) maze[i] = scan.nextLine().toCharArray();
            for (int i = 0; i < n; i++) Arrays.fill(dist[i], Integer.MAX_VALUE);
            dist[n-1][m-1] = 0;
            dfs(n-1, m-1);
            boolean bad = false, good = false;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (maze[i][j] == 'B') {
                        bad = true;
                        blockB(i, j);
                    }
                    if (maze[i][j] == 'G') good = true;
                }
            }
            if (!good) System.out.println("Yes");
            else {
                boolean goodescape = true;
                for (int i = 0; i < n && goodescape; i++) {
                    for (int j = 0; j < m; j++) {
                        if (maze[i][j] == 'G' && !canGoodEscape(i, j)) {
                            goodescape = false; break;
                        }
                    }
                }
                boolean newWall = false;
                for (int i = 0; i < n && !newWall; i++) {
                    for (int j = 0; j < m; j++) {
                        if (maze[i][j] == '.' && dist[i][j] == Integer.MAX_VALUE) {
                            newWall = true; break;
                        }
                    }
                }
                //for (int[] i: dist) System.out.println(Arrays.toString(i));
                if (goodescape && !bad) System.out.println("Yes");
                else if (goodescape && newWall) System.out.println("Yes");
                else System.out.println("No");
            }
        }
    }
    static boolean canGoodEscape(int i, int j) {
        for (int c: a) {
            if (i+c >= 0 && i+c < n && dist[i+c][j] != Integer.MAX_VALUE) return true;
            if (j+c >= 0 && j+c < m && dist[i][j+c] != Integer.MAX_VALUE) return true;
        }
        return false;
    }
    static void blockB(int i, int j) {
        for (int c: a) {
            if (i+c >= 0 && i+c < n && maze[i+c][j] == '.') dist[i+c][j] = Integer.MAX_VALUE;
            if (j+c >= 0 && j+c < m && maze[i][j+c] == '.') dist[i][j+c] = Integer.MAX_VALUE;
        }
    }
    static void dfs (int i, int j) {
        for (int c: a) {
            if (i+c >= 0 && i+c < n && (maze[i+c][j] == '.' || maze[i+c][j] == 'G')) {
                if (dist[i][j] + 1 < dist[i+c][j]) {
                    dist[i+c][j] = 1 + dist[i][j];
                    dfs(i+c, j);
                }
            }
            if (j+c >= 0 && j+c < m && (maze[i][j+c] == '.' || maze[i][j+c] == 'G')) {
                if (dist[i][j] + 1 < dist[i][j+c]) {
                    dist[i][j+c] = 1 + dist[i][j];
                    dfs(i, j+c);
                }
            }
        }
    }
}
