import java.io.*;
import java.math.*;
import java.util.*;

public class Solve {
    FastScanner in;
    PrintWriter out;

    static final int[] drow = {0, -1, 0, 1};
    static final int[] dcol = {1, 0, -1, 0};

    static boolean inBounds(int row, int col, int rows, int cols) {
        return (0 <= row &&
                0 <= col &&
                row < rows &&
                col < cols);
    }

    static class Point {
        int row, col;
        Point(int r, int c) {
            row = r;
            col = c;
        }
    }

    void solve() {
        int T = in.nextInt();
        while (0 < T--) {
            int n = in.nextInt();
            int m = in.nextInt();
            char[][] map = new char[n][m];
            int totalGood = 0;
            int totalBad = 0;
            for (int row = 0; row < n; row++) {
                map[row] = in.next().toCharArray();
                for (int col = 0; col < m; col++) {
                    if (map[row][col] == 'G') {
                        totalGood++;
                    } else if (map[row][col] == 'B') {
                        totalBad++;
                    }
                }
            }

            if (0 < totalGood &&
                ((2 <= n && map[n-2][m-1] == 'B') ||
                 (2 <= m && map[n-1][m-2] == 'B'))) {
                out.println("No");
            } else {
                // for (int row = 0; row < n; row++) {
                //     for (int col = 0; col < m; col++) {
                //         out.print(map[row][col]);
                //     }
                //     out.println();
                // }

                for (int row = 0; row < n; row++) {
                    for (int col = 0; col < m; col++) {
                        if (map[row][col] == 'B') {
                            for (int d = 0; d < 4; d++) {
                                int nrow = row + drow[d];
                                int ncol = col + dcol[d];
                                if (inBounds(nrow, ncol, n, m) && map[nrow][ncol] == '.') {
                                    map[nrow][ncol] = '#';
                                }
                            }
                        }
                    }
                }


                int numGood = 0;
                int numBad = 0;
                boolean[][] seen = new boolean[n][m];
                ArrayDeque<Point> ad = new ArrayDeque<>();

                if (map[n-1][m-1] == '.') {
                    seen[n-1][m-1] = true;
                    ad.add(new Point(n-1, m-1));
                }

                while ( ! ad.isEmpty()) {
                    Point curr = ad.poll();
                    if (map[curr.row][curr.col] == 'G') {
                        numGood++;
                    } else if (map[curr.row][curr.col] == 'B') {
                        numBad++;
                    }

                    for (int d = 0; d < 4; d++) {
                        int nrow = curr.row + drow[d];
                        int ncol = curr.col + dcol[d];
                        if (inBounds(nrow, ncol, n, m) &&
                            ! seen[nrow][ncol] &&
                            map[nrow][ncol] != '#') {

                            seen[nrow][ncol] = true;
                            ad.add(new Point(nrow, ncol));
                        }
                    }
                }

                // out.println(numGood + " " + totalGood + " " + numBad);
                out.println((numGood == totalGood && 0 == numBad) ? "Yes" : "No");

                // out.println();
                // for (int row = 0; row < n; row++) {
                //     for (int col = 0; col < m; col++) {
                //         out.print(map[row][col]);
                //     }
                //     out.println();
                // }

            }
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("Solve.in"));
            out = new PrintWriter(new File("Solve.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Solve().runIO();
    }
}
