//package Round648;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * @author sguar <shugangcao@gmail.com>
 * strive for greatness
 * Created on 2020-01-10
 */
public class D {
    InputStream is;
    PrintWriter out;


    private static final String INPUT_FILE_NAME = "/Users/sguar/IdeaProjects/kotlinLearn/src/input.txt";
    char [][] maze;
    boolean [][] vis;
    int n;
    int m;

    int [] nx = {-1, 0, 0, 1};
    int [] ny = {0, -1, 1, 0};

    void solve() {
        int t = ni();

        while (t -- > 0) {
            n = ni();
            m = ni();
            debug(n, m);
            maze = nm(n, m);
            debug(maze);
            int good = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (maze[i][j] == 'G') {
                        good++;
                    }
                }
            }

            vis = new boolean[n][m];

            boolean flag = !block(n - 1, m - 1);


            debug(maze);
            debug(flag);
            if (flag) {

                debug(good);
                init();
                debug(find(n - 1, m - 1));
                init();
                flag = find(n - 1, m - 1) == good;
            }

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

        }
    }

    private int find(int x, int y) {
        //debug(x, y, maze[x][y]);
        if (vis[x][y] || maze[x][y] == '#') {
            return 0;
        }
        vis[x][y] = true;

        int ans = 0;
        if (maze[x][y] == 'G') {
            ans++;
        }

        for (int i = 0; i < 4; i++) {
            int xi = x + nx[i];
            int yi = y + ny[i];
            if (xi >= 0 && xi < n && yi >= 0 && yi < m && !vis[xi][yi] && maze[xi][yi] != '#') {
                ans += find(xi, yi);
            }
        }
        return ans;
    }

    //让它无路可走
    private boolean block(int x, int y) {
        if (vis[x][y]) {
            return false;
        }
        vis[x][y] = true;
        if (maze[x][y] == '#') {
            return false;
        } else if (maze[x][y] == 'B') {
            return true;
        }


        for (int i = 0; i < 4; i++) {
            int xi = x + nx[i];
            int yi = y + ny[i];
            if (xi >= 0 && xi < n && yi >= 0 && yi < m && !vis[xi][yi] && maze[xi][yi] != '#') {
                if (maze[xi][yi] == 'B') {
                    if (maze[x][y] == '.') { //change
                        maze[x][y] = '#';
                    } else if (maze[x][y] == 'G') { //can't change
                        return true;
                    }
                    // no other
                } else { //A or .
                    if (block(xi, yi)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    private void init() {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                vis[i][j] = false;
            }
        }
    }

    class Pair {
        int x;
        int y;

        Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "x: " + x + ", y: " + y;
        }
    }

    public static long invl(long a, long mod) {
        long b = mod;
        long p = 1, q = 0;
        while (b > 0) {
            long c = a / b;
            long d;
            d = a;
            a = b;
            b = d % b;
            d = p;
            p = q;
            q = d - c * q;
        }
        return p < 0 ? p + mod : p;
    }


    void run() throws Exception {

        is = oj ? System.in : new FileInputStream(INPUT_FILE_NAME);
        out = new PrintWriter(System.out);

        long s = System.currentTimeMillis();
        solve();
        out.flush();
        debug(System.currentTimeMillis() - s + "ms");
    }

    public static void main(String[] args) throws Exception {
        new D().run();
    }

    private byte[] inbuf = new byte[1024];
    int lenbuf = 0;
    int ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void debug(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }

    private void debug(Object a, Object o) {
        if (!oj) {
            System.out.println(a.toString() + ": " + o.toString());
        }
    }
}