import java.util.*;

public class D {

    public static int count;
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int t = scn.nextInt();
        while (t-- > 0) {
            int n = scn.nextInt();
            int m = scn.nextInt();
            char c[][] = new char[n][m];
            scn.nextLine();
            for (int i = 0; i < n; ++i) {
                c[i] = scn.nextLine().toCharArray();
            }
            boolean ans = true;
            count = 0;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    if (c[i][j] == 'G') {
                        count++;
                    }
                }
            }
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    if (c[i][j] == 'B') {
                        boolean wall = putWall(c, i + 1, j, n, m);
                        if(!wall){
                            ans = false;
                            break;
                        }
                        wall = putWall(c, i - 1, j, n, m);
                        if(!wall){
                            ans = false;
                            break;
                        }
                        wall = putWall(c, i, j + 1, n, m);
                        if(!wall){
                            ans = false;
                            break;
                        }
                        wall = putWall(c, i, j - 1, n, m);
                        if (!wall) {
                            ans = false;
                            break;
                        }
                    }
                }
                if (!ans) {
                    break;
                }
            }
            if (!ans) {
                // System.out.println("Yay");
                System.out.println("No");
                continue;
            }
            int cnt = 0;
            c[n - 1][m - 1] = 'T';
            for (int i = n - 1; i >= 0; --i) {
                for (int j = m - 1; j >= 0; --j) {
                    if (c[i][j] == 'T') {
                        if (i - 1 >= 0) {
                            if (c[i - 1][j] == '.') {
                                c[i - 1][j] = 'T';
                            } else if (c[i - 1][j] == 'G') {
                                cnt++;
                                c[i - 1][j] = 'T';
                            }
                        }
                        if (j - 1 >= 0) {
                            if (c[i][j - 1] == '.') {
                                c[i][j - 1] = 'T';
                            } else if (c[i][j - 1] == 'G') {
                                cnt++;
                                c[i][j - 1] = 'T';
                            }
                        }
                    }
                }
            }
            if (cnt != count) {
                ans = false;
            }
            // for (int i = 0; i < n; ++i) {
            //     for (int j = 0; j < m; ++j) {
            //         System.out.print(c[i][j]);
            //     }
            //     System.out.println();
            // }
            if (ans) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    private static boolean putWall(char[][] c, int i, int j, int n, int m) {
        if(i == n-1 && j == m-1){
            if(count == 0){
                return true;
            } else {
                return false;
            }
        }
        if (i < 0 || i >= n || j < 0 || j >= m) {
            return true;
        }
        if (c[i][j] == 'G') {
            return false;
        }

        if (c[i][j] == '.') {
            c[i][j] = '#';
        }

        return true;

    }
}
