import java.util.*;
import java.io.*;

public class Codeforces{
    // Input
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.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() {
            String s = null;
            try {
                s = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return s;
        }

        public String nextParagraph() {
            String line = null;
            String ans = "";
            try {
                while ((line = reader.readLine()) != null) {
                    ans += line;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return ans;
        }
    }
    //Template
    static int mod = 998244353;
    static void printArray(int ar[]){ for(int x:ar) System.out.print(x+" ");}
    static void printArray(ArrayList<Integer> ar){ for(int x:ar) System.out.print(x+" ");}
    static long gcd(long a, long b){ if (a == 0) return b; return gcd(b%a, a);}
    static long power(long x, long y, int p) { long res = 1; x = x % p;  while (y > 0) { if((y & 1)==1) res = (res * x) % p; y = y >> 1;x = (x * x) % p;  } return res;}
    static void takeArrayInput(InputReader sc, int ar[]){ for(int i=0;i<ar.length;i++) ar[i]=sc.nextInt(); }
    static void takeArrayInput(InputReader sc, long ar[]){ for(int i=0;i<ar.length;i++) ar[i]=sc.nextLong(); }
    static void take2dArrayInput(InputReader sc, int ar[][]){ for(int i=0;i<ar.length;i++) for(int j=0;j<ar[i].length;j++) ar[i][j]=sc.nextInt(); }
    static void take2dArrayInput(InputReader sc, long ar[][]){ for(int i=0;i<ar.length;i++) for(int j=0;j<ar[i].length;j++) ar[i][j]=sc.nextLong(); }
    static ArrayList<ArrayList<Integer>> graph(InputReader sc, int n, int m){
        ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
        for(int i=0;i<n;i++) list.add(new ArrayList<Integer>());
        for(int i=0;i<m;i++){ int u = sc.nextInt(); int v = sc.nextInt(); list.get(u).add(v); list.get(v).add(u); }
        return list;
    }
    static void sieveOfEratosthenes(int n, ArrayList<Integer> pr) {
        // Create a boolean array "prime[0..n]" and initialize
        // all entries it as true. A value in prime[i] will
        // finally be false if i is Not a prime, else true.
        boolean prime[] = new boolean[n + 1];
        for (int i = 0; i < n; i++)
            prime[i] = true;
        for (int p = 2; p * p <= n; p++) {
            // If prime[p] is not changed, then it is a prime
            if (prime[p] == true) {
                // Update all multiples of p
                pr.add(p);
                for (int i = p * p; i <= n; i += p)
                    prime[i] = false;
            }
        }
    }

    // Write code here
    static class Data {
        int val;
        int type;
        public Data(int val, int type) {
            this.type = type;
            this.val = val;
        }
    }

    static boolean dfs(char ch[][], int mark[][], int i, int j, boolean setWall) {
        // System.out.println("I ama at = {i = " + i + " j = " + j+ " }, setWall =  " + setWall);
        if (i == ch.length-1 && j == ch[0].length-1) {
            if (ch[i][j]!='#') {
                return true;
            }
            return false;
        }
        if (i < 0 || j < 0 || i >=ch.length || j >= ch[0].length)
            return false;
        if (ch[i][j] == '#')
            return false;
        if (mark[i][j] == 1)
            return false;
        mark[i][j] = 1;
        boolean is = false;
        is = is || dfs(ch, mark, i-1, j, setWall);
        is = is || dfs(ch, mark, i, j-1, setWall);
        is = is || dfs(ch, mark, i, j+1, setWall);
        is = is || dfs(ch, mark, i+1, j, setWall);
        mark[i][j] = 0;
        return is;
    }

    public static void main(String args[]) {
        InputReader sc = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);
        int t = sc.nextInt();
        int i = 0 , j=0;
        for (int z = 0; z < t; z++) {
            int n=sc.nextInt(), m =sc.nextInt();
            char ch[][] = new char[n][m];
            int mark[][] = new int[n][m];
            for (i = 0 ; i < n ; i++) {
                String s = sc.nextLine();
                char c[] = s.toCharArray();
                for (j = 0 ; j < c.length; j++)
                    ch[i][j] = c[j];
            }
            if (ch[n-1][m-1] == '#' || ch[n-1][m-1] == 'B') {
                pw.println("No");
                continue;
            }
            for (i = 0 ; i < n; i++) {
                for (j = 0 ; j < m; j++) {
                    if (ch[i][j] == 'B') {
                        mark[i][j] = 1;
                        if (dfs(ch, mark, i-1, j, false) && ch[i-1][j] == '.') {
                            ch[i-1][j] = '#';
                        }
                        if (dfs(ch, mark, i+1, j, false) && ch[i+1][j] == '.') {
                            ch[i+1][j] = '#';
                        }
                        if (dfs(ch, mark, i, j-1, false) && ch[i][j-1] == '.') {
                            ch[i][j-1] = '#';
                        }
                        if (dfs(ch, mark, i, j+1, false) && ch[i][j+1] == '.') {
                            ch[i][j+1] = '#';
                        }
                        mark[i][j] = 0;
                    }
                }
            }
            boolean ans = true;
            for (i = 0 ; i < n; i++) {
                for (j = 0 ; j < m; j++) {
                    if (ch[i][j] == 'G') {
                        ans = ans && dfs(ch, mark, i, j, false);
                        // System.out.println("z = " + z + " ans = " + ans);
                    }
                }
                if (!ans)
                    break;
            }
            if (ans) {
                pw.println("Yes");
            } else {
                pw.println("No");
            }
        }
        pw.close();
    }
}