import java.io.*;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Stack;
import java.util.StringTokenizer;

public class D_ {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    private static String readToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public static void main(String[] args) throws IOException {
        int T = readInt();
        while (T-- > 0) solve();
        pw.close();
    }

    private static void solve() throws IOException {
        int n = readInt();
        int m = readInt();

        char[][] maze = new char[n][m];
        for (int i = 0; i < n; i++) {
            maze[i] = readToken().toCharArray();
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'B') {
                    if (i > 0 && maze[i - 1][j] == '.') maze[i - 1][j] = '#';
                    if (i < n - 1 && maze[i + 1][j] == '.') maze[i + 1][j] = '#';
                    if (j > 0 && maze[i][j - 1] == '.') maze[i][j - 1] = '#';
                    if (j < m - 1 && maze[i][j + 1] == '.') maze[i][j + 1] = '#';

                    if (i > 0 && maze[i - 1][j] == 'G' ||
                            i < n - 1 && maze[i + 1][j] == 'G' ||
                            j > 0 && maze[i][j - 1] == 'G' ||
                            j < m - 1 && maze[i][j + 1] == 'G') {
                        pw.println("No");
                        return;
                    }
                }
            }
        }

        int numberGood = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'G') numberGood++;
            }
        }

        Deque<Integer> toDo = new ArrayDeque<>();
        int[][] visited = new int[n][m];
        if (maze[n - 1][m - 1] != '#') {
            toDo.addLast(n - 1);
            toDo.addLast(m - 1);
            visited[n - 1][m - 1] = 1;
        }

        int goodEscaped = 0;
        while (!toDo.isEmpty()) {
            int row = toDo.pollFirst();
            int col = toDo.pollFirst();
            if (maze[row][col] == 'G') goodEscaped++;

            if (row > 0 && maze[row - 1][col] != '#' && visited[row - 1][col] == 0) {
                toDo.addLast(row - 1);
                toDo.addLast(col);
                visited[row - 1][col] = 1;
            }
            if (row < n - 1 && maze[row + 1][col] != '#' && visited[row + 1][col] == 0) {
                toDo.addLast(row + 1);
                toDo.addLast(col);
                visited[row + 1][col] = 1;
            }
            if (col > 0 && maze[row][col - 1] != '#' && visited[row][col - 1] == 0) {
                toDo.addLast(row);
                toDo.addLast(col - 1);
                visited[row][col - 1] = 1;
            }
            if (col < m - 1 && maze[row][col + 1] != '#' && visited[row][col + 1] == 0) {
                toDo.addLast(row);
                toDo.addLast(col + 1);
                visited[row][col + 1] = 1;
            }
        }

        if (goodEscaped == numberGood) {
            pw.println("Yes");
        } else {
            pw.println("No");
        }
    }
}
