import java.util.*;
import java.io.*;
 
public class D {
    private static int n, m;
    public static void main(String[] args) throws IOException {
        FastScanner input = new FastScanner(System.in);
        // Scanner input = new Scanner(new File("input.txt"));
        PrintWriter output = new PrintWriter(System.out);

        int[] xx = {-1, 0, 1, 0}, yy = {0, 1, 0, -1};
        int t = input.nextInt();
        for (int q = 0; q < t; q++) {
            n = input.nextInt();
            m = input.nextInt();
            char[][] maze = new char[n][m]; 
            for (int i = 0; i < n; i++) {
                maze[i] = input.next().toCharArray();
            }
            boolean escape = true;

            outerloop:
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (maze[i][j] == 'B') {
                        for (int k = 0; k < 4; k++) {
                            int x = i + xx[k];
                            int y = j + yy[k];
                            if (valid(x, y)) {
                                if (maze[x][y] == 'G') {
                                    escape = false;
                                    break outerloop;
                                } else {
                                    maze[x][y] = '#';
                                }
                            }
                        }
                    }
                }
            }
            boolean[][] reach = new boolean[n][m];
            if (maze[n - 1][m - 1] == '.') {
                reach[n - 1][m - 1] = true;
                Queue<Integer> queue = new LinkedList<>();
                queue.add(n * m - 1);
                while (!queue.isEmpty()) {
                    int current = queue.poll();
                    int currentX = current / m;
                    int currentY = current - currentX * m;
                    for (int k = 0; k < 4; k++) {
                        int x = currentX + xx[k];
                        int y = currentY + yy[k];
                        if (valid(x, y) && (maze[x][y] == '.' || maze[x][y] == 'G') && !reach[x][y]) {
                            reach[x][y] = true;
                            queue.add(x * m + y);
                        }
                    }
                }
            } 

            outerloop:
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (maze[i][j] == 'G' && !reach[i][j]) {
                        escape = false;
                        break outerloop;
                    }
                }
            }

            output.println(escape ? "Yes" : "No");
        }

        output.close();
    }

    private static boolean valid(int x, int y) {
        return 0 <= x && x < n && 0 <= y && y < m;
    }    
 
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
 
        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }
 
        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        String nextLine() throws IOException {
            return br.readLine();
        }
 
        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
 
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}
