import java.util.*;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Scanner;
public class A {

    public  static boolean dfs(char[][] matrix)
    {
        //#aarjae
        //Taken from solution of Journey to the moon |Hackerrank
        //https://www.hackerrank.com/challenges/journey-to-the-moon/problem
        //The non commented part is the core of dfs ,just put you code
        int row =matrix.length;
        int col=matrix[0].length;
        Queue<Integer> queue= new LinkedList<>();
        int touched[][] =new int[row][col];
        //long sum =0;
        //long count =0;
        //long ans =0;

        queue.add(row-1);
        queue.add(col-1);

        while(!queue.isEmpty())
        {
            int p=queue.poll();
            int q=queue.poll();

            if(touched[p][q]==0&&(matrix[p][q]+"").equals("#")==false);
            {
                if(p>0&&touched[p][q]==0&&(matrix[p][q]+"").equals("#")==false){queue.add(p-1);
                        queue.add(q);}

                if(q>0&&touched[p][q]==0&&(matrix[p][q]+"").equals("#")==false){queue.add(p);
                    queue.add(q-1);}

                if(p<row-1&&touched[p][q]==0&&(matrix[p][q]+"").equals("#")==false){queue.add(p+1);
                    queue.add(q);}

                if(q<col-1&&touched[p][q]==0&&(matrix[p][q]+"").equals("#")==false){queue.add(p);
                    queue.add(q+1);}
            }
            touched[p][q]=1;
        }

        for(int i=0;i<row;i++)
        {
            for(int j=0;j<col;j++)
            {
                if ((matrix[i][j]+"").equals("G")&&touched[i][j]==0)
                {
                    return false;
                }
            }
        }
        return true;
    }

    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int cases = sc.nextInt();
        for(int i=0;i<cases;i++)
        {
            boolean ans=true;
            int n=sc.nextInt();
            int m=sc.nextInt();
            char matrix[][]=new char[n][m];
            for(int j=0;j<n;j++)
            {
               String s=sc.next();
               matrix[j]=s.toCharArray();
            }

            boolean bool=true;
            for(int j=0;j<n;j++)
            {
                for(int k=0;k<m;k++)
                {
                    if((matrix[j][k]+"").equals("B"))
                    {
                        if(j>0&&(matrix[j-1][k]+"").equals("G"))
                        {bool=false;}
                        if(k>0&&(matrix[j][k-1]+"").equals("G"))
                        {bool=false;}
                        if(j<n-1&&(matrix[j+1][k]+"").equals("G"))
                        {bool=false;}
                        if(k<m-1&&(matrix[j][k+1]+"").equals("G"))
                        {bool=false;}


                    }
                }
            }


            for(int j=0;j<n;j++)
            {
                for(int k=0;k<m;k++)
                {
                    if((matrix[j][k]+"").equals("B"))
                    {
                        if(j>0){matrix[j-1][k]='#';}
                        if(k>0){matrix[j][k-1]='#';}
                        if(j<n-1){matrix[j+1][k]='#';}
                        if(k<m-1){matrix[j][k+1]='#';}

                    }
                }
            }



            if(bool) {
                boolean anss = dfs(matrix);

                if (anss) {
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
            }
            else {System.out.println("No");}

        }
    }
}
