
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        ScanReader in = new ScanReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Solver main = new Solver();
        int test = in.scanInt();
        for (int i = 1; i <= test; i++) main.solve(i, in, out);
        out.close();
    }
}

class Solver {
    char[][] ar;
    boolean[][] visited;
    int n, m;

    public void solve(int testNumber, ScanReader in, PrintWriter out) throws IOException {
        n = in.scanInt();
        m = in.scanInt();
        ar = new char[n][];
        for (int i = 0; i < n; i++) ar[i] = in.scanString().toCharArray();
        visited = new boolean[n][m];
        dfs(n - 1, m - 1);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (ar[i][j] == 'G' && !visited[i][j]) {
                    out.println("No");
                    return;
                }
                if (ar[i][j] == 'B') {
                    if (i - 1 >= 0 && ar[i - 1][j] == '.') ar[i - 1][j] = '#';
                    if (i + 1 < n && ar[i + 1][j] == '.') ar[i + 1][j] = '#';
                    if (j - 1 >= 0 && ar[i][j - 1] == '.') ar[i][j - 1] = '#';
                    if (j + 1 < m && ar[i][j + 1] == '.') ar[i][j + 1] = '#';
                }
            }
        }
        visited = new boolean[n][m];
        if (ar[n - 1][m - 1] == '.') dfs(n - 1, m - 1);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (ar[i][j] == 'G' && !visited[i][j]) {
                    out.println("No");
                    return;
                } else if (ar[i][j] == 'B' && visited[i][j]) {
                    out.println("No");
                    return;
                }
            }
        }
        out.println("Yes");
    }

    private void dfs(int x, int y) {
        visited[x][y] = true;
        if (isValid(x - 1, y)) dfs(x - 1, y);
        if (isValid(x + 1, y)) dfs(x + 1, y);
        if (isValid(x, y - 1)) dfs(x, y - 1);
        if (isValid(x, y + 1)) dfs(x, y + 1);
    }

    private boolean isValid(int x, int y) {
        return x >= 0 && x < n && y >= 0 && y < m && ar[x][y] != '#' && !visited[x][y];
    }
}


class ScanReader {
    private final byte[] buf = new byte[4 * 1024];
    private final BufferedInputStream in;
    private int index;
    private int total;

    public ScanReader(InputStream inputStream) {
        in = new BufferedInputStream(inputStream);
    }

    private int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) return -1;
        }
        return buf[index++];
    }

    public char scanChar() throws IOException {
        int c = scan();
        while (isWhiteSpace(c)) c = scan();
        return (char) c;
    }


    public int scanInt() throws IOException {
        int integer = 0;
        int n = scan();
        while (isWhiteSpace(n)) n = scan();
        int neg = 1;
        if (n == '-') {
            neg = -1;
            n = scan();
        }
        while (!isWhiteSpace(n)) {
            if (n >= '0' && n <= '9') {
                integer *= 10;
                integer += n - '0';
                n = scan();
            }
        }
        return neg * integer;
    }

    public String scanString() throws IOException {
        int c = scan();
        while (isWhiteSpace(c)) c = scan();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = scan();
        } while (!isWhiteSpace(c));
        return res.toString();
    }

    private boolean isWhiteSpace(int n) {
        return n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1;
    }

    public long scanLong() throws IOException {
        long integer = 0;
        int n = scan();
        while (isWhiteSpace(n)) n = scan();
        int neg = 1;
        if (n == '-') {
            neg = -1;
            n = scan();
        }
        while (!isWhiteSpace(n)) {
            if (n >= '0' && n <= '9') {
                integer *= 10;
                integer += n - '0';
                n = scan();
            }
        }
        return neg * integer;
    }

    public void scanLong(long[] A) throws IOException {
        for (int i = 0; i < A.length; i++) A[i] = scanLong();
    }

    public void scanInt(int[] A) throws IOException {
        for (int i = 0; i < A.length; i++) A[i] = scanInt();
    }

    public double scanDouble() throws IOException {
        int c = scan();
        while (isWhiteSpace(c)) c = scan();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = scan();
        }
        double res = 0;
        while (!isWhiteSpace(c) && c != '.') {
            if (c == 'e' || c == 'E') {
                return res * Math.pow(10, scanInt());
            }
            res *= 10;
            res += c - '0';
            c = scan();
        }
        if (c == '.') {
            c = scan();
            double m = 1;
            while (!isWhiteSpace(c)) {
                if (c == 'e' || c == 'E') {
                    return res * Math.pow(10, scanInt());
                }
                m /= 10;
                res += (c - '0') * m;
                c = scan();
            }
        }
        return res * sgn;
    }

}