import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.StringTokenizer;

public class Task4 {

    public static void main(String[] args) throws IOException {
        new Task4().solve();
    }

    public void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int t = Integer.parseInt(f.readLine());
        for (int t1 = 0; t1 < t; t1++) {
            StringTokenizer tokenizer = new StringTokenizer(f.readLine());
            int n = Integer.parseInt(tokenizer.nextToken());
            int m = Integer.parseInt(tokenizer.nextToken());
            char[][] map = new char[n][m];

            for (int i = 0; i < n; i++) {
                char[] line = f.readLine().toCharArray();
                map[i] = line;
            }

            boolean notPossible = false;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (map[i][j] == 'B') {
                        if (i != 0) {
                            if (!checkMap(map, i - 1, j)) {
                                notPossible = true;
                                break;
                            }
                        }
                        if (i != n - 1) {
                            if (!checkMap(map, i + 1, j)) {
                                notPossible = true;
                                break;
                            }
                        }
                        if (j != 0) {
                            if (!checkMap(map, i, j - 1)) {
                                notPossible = true;
                                break;
                            }
                        }
                        if (j != m - 1) {
                            if (!checkMap(map, i, j + 1)) {
                                notPossible = true;
                                break;
                            }
                        }
                    }
                }
                if (notPossible) break;
            }
            if (notPossible) {
                out.println("No");
                continue;
            }

            boolean[][] canExit = new boolean[n][m];
            ArrayDeque<int[]> stack = new ArrayDeque<int[]>();
            int[] end = {n - 1, m - 1};
            if (map[n - 1][m - 1] != '#') {
                stack.addLast(end);
            }
            canExit[n - 1][m - 1] = true;
            while (!stack.isEmpty()) {
                int[] coord = stack.removeLast();
                tryVisit(map, canExit, stack, coord[0] - 1, coord[1], n, m);
                tryVisit(map, canExit, stack, coord[0] + 1, coord[1], n, m);
                tryVisit(map, canExit, stack, coord[0], coord[1] - 1, n, m);
                tryVisit(map, canExit, stack, coord[0], coord[1] + 1, n, m);
            }


            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (map[i][j] == 'G' && !canExit[i][j]) {
                        notPossible = true;
                    }
                }
            }

            if (notPossible) {
                out.println("No");
            } else {
                out.println("Yes");
            }
        }

        out.close();
    }

    private void tryVisit(char[][] map, boolean[][] canExit, ArrayDeque<int[]> stack, int i, int j, int n, int m) {
        if (i < 0 || i >= n) return;
        if (j < 0 || j >= m) return;
        if (canExit[i][j]) return;
        if (map[i][j] == '#') return;

        canExit[i][j] = true;
        int[] ar = {i, j};
        stack.addLast(ar);
    }

    private boolean checkMap(char[][] map, int i, int j) {
        if (map[i][j] == 'G') {
            return false;
        }
        if (map[i][j] == '.') {
            map[i][j] = '#';
        }

        return true;
    }
}
