import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayDeque;
import java.io.InputStream;

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

    static class DSolveTheMaze {
        private final int[] dx = {0, 1, 0, -1};
        private final int[] dy = {1, 0, -1, 0};
        private int n;
        private int m;
        private boolean[] vis;
        boolean[] poss;
        private boolean[][] unWalkable;

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int t = in.nextInt();
            int jj = 0;
            while (t-- > 0) {
                ++jj;
                n = in.nextInt();
                m = in.nextInt();
                poss = new boolean[n * m];
                vis = new boolean[n * m];
                unWalkable = new boolean[n][m];
                Queue<Integer> starts = new ArrayDeque<>();
                String[] grid = new String[n];
                for (int i = 0; i < n; i++) {
                    String s = in.next();
                    if (jj == 20) {
                        System.err.println(s);
                    }
                    grid[i] = s;
                    for (int j = 0; j < s.length(); j++) {
                        char c = s.charAt(j);
                        if (c == 'B' || c == 'G') unWalkable[i][j] = false;
                        if (c == 'B') {
                            for (int k = 0; k < dx.length; k++) {
                                int nx = i + dx[k];
                                int ny = j + dy[k];
                                if (valid(nx, ny)) {
                                    if (nx >= i || ny >= j || (grid[nx].charAt(ny) != 'G' && grid[nx].charAt(ny) != 'B')) {
                                        unWalkable[nx][ny] = true;
                                    }
                                }
                            }
                        } else if (c == '#') unWalkable[i][j] = true;
                        else if (c == 'G') {
                            starts.add(i * m + j);
                        }
                    }
                }
                boolean invalid = false;
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        if (grid[i].charAt(j) == 'B') {
                            for (int k = 0; k < dx.length; k++) {
                                int nx = i + dx[k];
                                int ny = j + dy[k];
                                if (valid(nx, ny)) {
                                    if (grid[nx].charAt(ny) == 'G') {
                                        invalid = true;
                                    }
                                }
                            }
                        }
                    }
                }
                while (!invalid && !starts.isEmpty()) {
                    int curr = starts.poll();
                    if (!dfs(curr)) {
                        invalid = true;
                    }
                }
                if (invalid) {
                    out.println("No");
                } else
                    out.println("Yes");

            /*
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    out.print(poss[i * m + j] ? 1 : 0);
                }
                out.println();
            }
            */
            }
        }

        private boolean dfs(int curr) {
            if (vis[curr]) return poss[curr];
            vis[curr] = true;
            int currX = curr / m;
            int currY = curr % m;
            if (unWalkable[currX][currY]) return false;
            if (currX == (n - 1) && (currY == m - 1)) {
                poss[curr] = true;
                return true;
            }
            for (int i = 0; i < dx.length; i++) {
                int nx = currX + dx[i];
                int ny = currY + dy[i];
                if (valid(nx, ny)) {
                    boolean b = dfs(nx * m + ny);
                    if (b) {
                        poss[curr] = true;
                        break;
                    }
                }
            }
            return poss[curr];
        }

        private boolean valid(int nx, int ny) {
            return nx >= 0 && ny >= 0 && nx < n && ny < m;
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

