import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Reader in = new Reader();
    public static void main(String[] args) throws IOException {
        Main solver = new Main();
        solver.solve();
        out.flush();
        out.close();
 
    }
 
    static long INF = (long)1e18;
    static int maxn = (int)2e6+5;
    static int mod  = 1000*1000*1000+7;
    static int n,m,q,k,t;
    
    static char[][] c;
    static boolean[][] visb, visg;
    
    void solve() throws IOException{
        t = in.nextInt();
        
        while (t --> 0) {
            n = in.nextInt();
            m = in.nextInt();
            
            ArrayDeque<Node> bq = new ArrayDeque<>();
            ArrayDeque<Node> gq = new ArrayDeque<>();
            
            visb = new boolean[n][m];
            visg = new boolean[n][m];
            String s;
            c = new char[n][m];
            
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                s = in.next();
                for (int j = 0; j < m; j++) {
                    c[i][j] = s.charAt(j);
                    if (c[i][j] == 'B') bq.add(new Node(i, j));
                    else if (c[i][j] == 'G') {
                        gq.add(new Node(i, j));
                        cnt++;
                    }
                }
            }
            
            int xx = 0, yy = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (c[i][j] == 'B') {
                        for (int z = 0; z < 4; z++) {
                            xx = i + dx[z];
                            yy = j + dy[z];
                            if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                                if (c[xx][yy] == '.') c[xx][yy] = '#';
                            }
                        }
                    }
                }
            }
            
            bfs(bq, 0);
            bfs(gq, 1);
            if ((!visg[n-1][m-1] && cnt != 0) || visb[n-1][m-1]) out.println("No");
            else out.println("Yes");
        }
    }
    
    //<>
    
    static int[] dx = {-1,0,0,1};
    static int[] dy = {0, 1, -1, 0};
    
    static void bfs(ArrayDeque<Node> q, int tt) {
        Node elm;
        while (q.size() != 0) {
            elm = q.remove();
            if (tt == 0) visb[elm.x][elm.y] = true;
            else visg[elm.x][elm.y] = true;
            
            int xx, yy;
            for (int i = 0; i < 4; i++) {
                xx = elm.x + dx[i];
                yy = elm.y + dy[i];
                if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                    if (tt == 0 && !visb[xx][yy] && c[xx][yy] != '#') {
                        visb[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    } else if (tt == 1 && !visg[xx][yy] && c[xx][yy] != '#') {
                        visg[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    }
                }
            }
        }
    }

    static class Node {
        int x, y;
        Node (int x, int y) {
            this.x = x;
            this.y = y;
        }
    }    
    static class Reader {
 
    private InputStream mIs;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
 
    public Reader() {
        this(System.in);
    }
 
    public Reader(InputStream is) {
        mIs = is;
    }
 
    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();
 
    }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = mIs.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }
 
    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }
 
    public String next() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
 
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
 
    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
 
    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
 
    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
 
    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }
 
    }
}