//package com.company;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;


public class Main {


    public static void showArr(int[] arr){
        int n=arr.length;
        for(int i=0;i<n;i++){
            System.out.print(arr[i]+" ");
        }
    }
    public static long gcd(long x, long y) {
        if (x == 0)
            return y;
        return gcd(y % x, x);
    }

    public static boolean twoPow (long n)
    {
        return n!=0 && ((n&(n-1)) == 0);
    }
    private static int[][] arr;
    public static void main(String args[]) throws IOException {
        Scanner in  = new Scanner(System.in);
        int t = in.nextInt();
//        int t=1;
        for (int jay = 0; jay < t; jay++) {
            int n = in.nextInt();
            int m = in.nextInt();
            arr = new int[n][m];
            int g=0;
            int x=0; int y=0;
            for(int i=0;i<n;i++){
                String ch = in.next();
                for(int j=0;j<m;j++){
//                    System.out.println(ch.charAt(j));
                    if(ch.charAt(j)=='.')arr[i][j]=0;
                    if(ch.charAt(j)=='#')arr[i][j]=1;
                    if(ch.charAt(j)=='B')arr[i][j]=2;
                    if(ch.charAt(j)=='G'){arr[i][j]=3;g+=1;x=i;y=j;}
                }
            }
            int flag=0;

            for(int i=0;i<n;i++) {
                for (int j = 0; j < m; j++) {
                    if(arr[i][j]==2){
                        boolean val = true;
                        val = val && modf(i+1,j);
                        val = val && modf(i-1,j);
                        val = val && modf(i,j+1);
                        val = val && modf(i,j-1);
                        if(!val) {
                            flag=1;
                            break;
                        }
                    }
                }
            }
            if(flag==1) System.out.println("No");
            else if(g==0){
                if (arr[n-1][m-1]!=2) System.out.println("Yes");
                else System.out.println("No");
            }
            else {

                visited = new int[n][m];
                cnt = g;

                if (checkG(x,y) && chekr(n,m,x,y) && cnt==0) System.out.println("Yes");
                else System.out.println("No");
            }
        }
    }

    private static boolean modf(int x, int y) {
        if(x>=0 && y>=0 && x<arr.length && y<arr[0].length) {
            if(arr[x][y]==0) arr[x][y] = 1;
            if(arr[x][y]==3) return false;
        }
        return true;
    }


    private static int cnt;
    private static int[][] visited;

    private static boolean chekr(int n, int m, int x, int y) {
//        System.out.println(x+" JAYYYYYYYYYYY "+y);
        int cur = arr[x][y];

        visited[x][y] = 1;
        if(cur==3) cnt-=1;

        if(x==n-1 && y==m-1){
            return true;
        }
        else {
            boolean val = false;

            if(checkG(x,y-1)) val = val  || chekr(n,m,x,y-1);
            if(checkG(x,y+1)) val = val  || chekr(n,m,x,y+1);
            if(checkG(x-1,y)) val = val  || chekr(n,m,x-1,y);
            if(checkG(x+1,y)) val = val  || chekr(n,m,x+1,y);

            return val;
        }
    }

    private static boolean checkG(int x, int i) {
        int n = arr.length;
        int m = arr[0].length;
        if(x>=0 && x<n && i>=0 && i<m && visited[x][i]==0 && arr[x][i]!=1 && arr[x][i]!=2) return true;
        return false;
    }
}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}
