//created by Whiplash99
import java.io.*;
import java.util.*;
public class D
{
    private static boolean reach[][];
    private static void DFS(char str[][], int i, int j, int N, int M)
    {
        if(i>=N) return;
        if(i<0) return;
        if(j>=M) return;
        if(j<0) return;
        if(str[i][j]=='#') return;
        if(reach[i][j]) return;

        reach[i][j]=true;
        DFS(str,i+1,j,N,M);
        DFS(str,i,j+1,N,M);
        DFS(str,i-1,j,N,M);
        DFS(str,i,j-1,N,M);
    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        int T=Integer.parseInt(br.readLine().trim());
        StringBuilder sb=new StringBuilder();

        while(T-->0)
        {
            String s[]=br.readLine().trim().split(" ");
            N=Integer.parseInt(s[0]);
            int M=Integer.parseInt(s[1]);

            char str[][]=new char[N][M];
            for(i=0;i<N;i++) str[i]=br.readLine().trim().toCharArray();


            boolean flag=true;
            outer: for(i=0;i<N;i++)
            {
                for(int j=0;j<M;j++)
                {
                    if(str[i][j]=='B')
                    {
                        if(i>0&&str[i-1][j]=='G') flag=false;
                        if(j>0&&str[i][j-1]=='G') flag=false;
                        if(i<N-1&&str[i+1][j]=='G') flag=false;
                        if(j<M-1&&str[i][j+1]=='G') flag=false;
                        if(i==N-1&&j==M-1) flag=false;

                        if(!flag) break outer;

                        if(i>0&&str[i-1][j]=='.') str[i-1][j]='#';
                        if(j>0&&str[i][j-1]=='.') str[i][j-1]='#';
                        if(i<N-1&&str[i+1][j]=='.') str[i+1][j]='#';
                        if(j<M-1&&str[i][j+1]=='.') str[i][j+1]='#';
                    }
                }
            }

            reach=new boolean[N][M];
            reach[N-1][M-1]=true;

            if(str[N-1][M-1]!='#')
            {
                DFS(str, N - 2, M - 1, N, M);
                DFS(str, N - 1, M - 2, N, M);
            }

            outer: for(i=0;i<N;i++)
            {
                for(int j=0;j<M;j++)
                {
                    if(str[i][j]=='G')
                    {
                        flag=reach[i][j];
                        if(!flag) break outer;
                    }
                }
            }

            sb.append(flag?"Yes":"No").append("\n");
        }
        System.out.println(sb);
    }
}