import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int t=Integer.parseInt(br.readLine());
        for(int x=0;x<t;x++)
        {
            String str[]=br.readLine().split(" ");
            int n=Integer.parseInt(str[0]);
            int m=Integer.parseInt(str[1]);
            char arr[][]=new char[n][];
            for(int i=0;i<n;i++)
            arr[i]=br.readLine().toCharArray();
            Queue<String> queue=new LinkedList<>();
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(arr[i][j]=='B')
                    queue.add(i+" "+j);
                }
            }
            while(!queue.isEmpty())
            {
                String ver=queue.poll();
                int u=Integer.parseInt(ver.split(" ")[0]);
                int v=Integer.parseInt(ver.split(" ")[1]);
                if(u-1>=0&&arr[u-1][v]=='.')
                arr[u-1][v]='#';
                if(v-1>=0&&arr[u][v-1]=='.')
                arr[u][v-1]='#';
                if(v+1<=m-1&&arr[u][v+1]=='.')
                arr[u][v+1]='#';
                if(u+1<=n-1&&arr[u+1][v]=='.')
                arr[u+1][v]='#';
            }
            queue.clear();
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(arr[i][j]=='G')
                    queue.add(i+" "+j);
                }
            }
            boolean ok=true;
            while(!queue.isEmpty())
            {
                String ver=queue.poll();
                int u=Integer.parseInt(ver.split(" ")[0]);
                int v=Integer.parseInt(ver.split(" ")[1]);
                boolean mat[][]=new boolean[n][m];
                boolean vis[][]=new boolean[n][m];
                Queue<String> queue2=new LinkedList<>();
                queue2.add(u+" "+v);
                mat[u][v]=true;
                vis[u][v]=true;
                while(!queue2.isEmpty())
                {
                    String st=queue2.poll();
                    u=Integer.parseInt(st.split(" ")[0]);
                    v=Integer.parseInt(st.split(" ")[1]);
                    if(u-1>=0&&arr[u-1][v]!='#'&&!vis[u-1][v])
                    {queue2.add((u-1)+" "+v);vis[u-1][v]=true;mat[u-1][v]=true;}
                    if(v-1>=0&&arr[u][v-1]!='#'&&!vis[u][v-1])
                    {queue2.add(u+" "+(v-1));vis[u][v-1]=true;mat[u][v-1]=true;}
                    if(v+1<=m-1&&arr[u][v+1]!='#'&&!vis[u][v+1])
                    {queue2.add(u+" "+(v+1));vis[u][v+1]=true;mat[u][v+1]=true;}
                    if(u+1<=n-1&&arr[u+1][v]!='#'&&!vis[u+1][v])
                    {queue2.add((u+1)+" "+v);vis[u+1][v]=true;mat[u+1][v]=true;}
                }
                if(!mat[n-1][m-1])
                {
                    ok=false;
                    break;
                }
            }
            if(ok&&arr[n-1][m-1]!='B')
            pw.println("Yes");
            else
            pw.println("No");
        }
        pw.flush();
        pw.close();
    }
}