import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author masterbios
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSolveTheMaze solver = new DSolveTheMaze();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSolveTheMaze {
        final char good = 'G';
        final char bad = 'B';
        final char empty = '.';
        final char wall = '#';

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            try {
                int dir[][] = {
                        {0, -1}, {-1, 0}, {1, 0}, {0, 1}
                };
                int t = in.nextInt();
                while (t-- > 0) {
                    int r = in.nextInt(), c = in.nextInt();
                    char a[][] = new char[r][];
                    for (int i = 0; i < r; i++) a[i] = in.next().toCharArray();
                    for (int i = 0; i < r; i++) {
                        for (int j = 0; j < c; j++) {
                            if (a[i][j] == bad) {
                                for (int k = 0; k < 4; k++) {
                                    int nx = i + dir[k][0], ny = j + dir[k][1];
                                    if (nx < 0 || nx >= r || ny < 0 || ny >= c || a[nx][ny] != empty) continue;
                                    a[nx][ny] = wall;
                                }
                            }
                        }
                    }
                    Queue<int[]> q = new LinkedList<>();
                    boolean vis[][] = new boolean[r][c];
                    if (a[r - 1][c - 1] != wall) {
                        q.offer(new int[]{r - 1, c - 1});
                        vis[r - 1][c - 1] = true;
                    }

                    while (!q.isEmpty()) {
                        int x[] = q.poll();
                        for (int k = 0; k < 4; k++) {
                            int nx = x[0] + dir[k][0], ny = x[1] + dir[k][1];
                            if (nx < 0 || nx >= r || ny < 0 || ny >= c || a[nx][ny] == wall || vis[nx][ny]) continue;
                            vis[nx][ny] = true;
                            q.offer(new int[]{nx, ny});
                        }
                    }
                    boolean flag = true;
                    for (int i = 0; i < r; i++) {
                        for (int j = 0; j < c; j++) {
                            if (a[i][j] == bad && vis[i][j]) {
                                flag = false;
                                break;
                            }
                            if (a[i][j] == good && !vis[i][j]) {
                                flag = false;
                                break;
                            }
                        }
                        if (!flag) break;
                    }
                    String ans = flag ? "Yes" : "No";
                    out.println(ans);
                }
            } catch (IOException e) {

            }
        }

    }

    static class FastReader {
        private byte[] buf = new byte[1024];
        private int index;
        private InputStream in;
        private int total;

        public FastReader(InputStream in) {
            this.in = in;
        }

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

        public int nextInt() 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();
                } else {
                    throw new InputMismatchException();
                }
            }
            return neg * integer;
        }

        public String next() throws IOException {
            StringBuilder sb = new StringBuilder();
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            while (!isWhiteSpace(n)) {
                sb.append((char) n);
                n = scan();
            }
            return sb.toString();
        }

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

    }
}

