import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.StringTokenizer;

public class Solve8 {

    public static void main(String[] args) throws IOException {
        PrintWriter pw = new PrintWriter(System.out);
        new Solve8().solve(pw);
        pw.flush();
        pw.close();
    }

    public void solve(PrintWriter pw) throws IOException {
        FastReader sc = new FastReader();
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt(), m = sc.nextInt();
            char[][] c = new char[n][m];
            for (int i = 0; i < n; i++) {
                c[i] = sc.next().toCharArray();
            }
            int s = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (c[i][j] == 'G') {
                        ++s;
                    }
                    if (c[i][j] == 'B') {
                        if (i - 1 >= 0 && c[i - 1][j] == '.') {
                            c[i - 1][j] = '#';
                        }
                        if (i + 1 < n && c[i + 1][j] == '.') {
                            c[i + 1][j] = '#';
                        }
                        if (j - 1 >= 0 && c[i][j - 1] == '.') {
                            c[i][j - 1] = '#';
                        }
                        if (j + 1 < m && c[i][j + 1] == '.') {
                            c[i][j + 1] = '#';
                        }
                    }
                }
            }

            ArrayDeque<Pair> q = new ArrayDeque();
            boolean[][] vis = new boolean[n][m];
            int cnt1 = 0, cnt2 = 0;
            if (c[n - 1][m - 1] != '#') {
                vis[n - 1][m - 1] = true;
                q.add(new Pair(n - 1, m - 1));
                cnt1 += c[n - 1][m - 1] == 'G' ? 1 : 0;
                cnt2 += c[n - 1][m - 1] == 'B' ? 1 : 0;
            }
            int[] x = {0, 0, -1, 1};
            int[] y = {1, -1, 0, 0};
            while (!q.isEmpty()) {
                Pair p = q.removeFirst();
                for (int k = 0; k < 4; k++) {
                    int newi = p.i + y[k], newj = p.j + x[k];
                    if (newi >= 0 && newi < n && newj >= 0 && newj < m && !vis[newi][newj] && c[newi][newj] != '#') {
                        q.add(new Pair(newi, newj));
                        vis[newi][newj] = true;
                        cnt1 += c[newi][newj] == 'G' ? 1 : 0;
                        cnt2 += c[newi][newj] == 'B' ? 1 : 0;
                    }
                }
            }
            if (cnt2 == 0 && cnt1 == s) {
                pw.println("Yes");
            } else {
                pw.println("No");
            }
        }
    }

    class Pair {

        int i, j;

        public Pair(int i, int j) {
            this.i = i;
            this.j = j;
        }
    }

    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
            }
        }

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

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
            }
            return null;
        }

        public boolean hasNext() throws IOException {
            if (st != null && st.hasMoreTokens()) {
                return true;
            }
            String s = br.readLine();
            if (s == null || s.isEmpty()) {
                return false;
            }
            st = new StringTokenizer(s);
            return true;
        }
    }
}
