/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{   static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static void main(String[] args)
    {
        FastReader sc=new FastReader();
     	int t= sc.nextInt();
     	while(t-->0)
     	{
     	    int n= sc.nextInt();
     	    int m= sc.nextInt();
     	    char a[][]= new char[n][m];
     	    int count=0,c=0;
     	    for(int i=0;i<n;i++)
     	    {
     	        String s= sc.nextLine();
     	        for(int j=0;j<m;j++)
     	        {
     	            a[i][j]= s.charAt(j);
     	            if(a[i][j]=='G')
     	            count++;
     	        }
     	    }
     	    if(count==0 && a[n-1][m-1]!='B')
     	    System.out.println("Yes");
     	    else if(a[n-1][m-1]=='B' || a[n-1][m-1]=='#')
     	    System.out.println("No");
     	    else
     	    {
     	        int flag=0;
     	        for(int i=0;i<n;i++)
     	        {
     	            for(int j=0;j<m;j++)
     	            {
     	                if(a[i][j]=='B')
     	                {
     	                    if(i>0)
     	                    {
     	                        if(a[i-1][j]=='G')
     	                        {
     	                            flag=1;
     	                            break;
     	                        }
     	                        else
     	                        a[i-1][j]='#';
     	                    }
     	                    if(i<n-1)
     	                    {
     	                        if(a[i+1][j]=='G')
     	                        {
     	                            flag=1;
     	                            break;
     	                        }
     	                        else
     	                        a[i+1][j]='#';
     	                    }
     	                    if(j>0)
     	                    {
     	                        if(a[i][j-1]=='G')
     	                        {
     	                            flag=1;
     	                            break;
     	                        }
     	                        else
     	                        a[i][j-1]='#';
     	                    }
     	                    if(j<m-1)
     	                    {
     	                        if(a[i][j+1]=='G')
     	                        {
     	                            flag=1;
     	                            break;
     	                        }
     	                        else
     	                        a[i][j+1]='#';
     	                    }
     	                }
     	            }
     	                if(flag==1)
     	                break;
     	        }
     	        if(flag==1)
     	        System.out.println("No");
     	        else
     	        {
     	            if(a[n-1][m-1]=='#')
     	            System.out.println("No");
     	            else
     	            {
                        if(a[n-1][m-1]=='G')
                        c++;
     	                a[n-1][m-1]='y';
     	                for(int i=n-1;i>=0;i--)
     	                {
     	                    for(int j=m-1;j>=0;j--)
     	                    {
     	                        if((i<n-1 && a[i+1][j]=='y') ||(j<m-1 && a[i][j+1]=='y'))
     	                        {
     	                            if(a[i][j]=='G')
     	                            c++;
     	                            a[i][j]='y';
     	                        }
     	                    }
     	                }
     	                if(c==count)
     	                System.out.println("Yes");
     	                else 
     	                System.out.println("No");
     	            }
     	        }
     	    }
     	}
    }
	static class Pair
	{
	    int x;
	    int y;
	    public Pair(int a, int b)
	    {
	        x=a;
	        y=b;
	    }
	}
}
