import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
    static int r[]={0,1,0,-1};
    static int c[]={1,0,-1,0};
    static int count;
    static boolean isValid(String s[],boolean visited[][],int i,int j,int n,int m){
        if(i>=n||j>=m) return false;
        if(i<0||j<0) return false;
        if(visited[i][j])return false;
        if(s[i].charAt(j)=='#') return false;
        return true;
    }
    static void DFS(String s[],boolean visited[][],int i,int j,int n,int m){
        if(!isValid(s,visited,i,j,n,m)) return;
        visited[i][j]=true;
        for(int l=0;l<4;l++){
            int ai=i+r[l];
            int aj=j+c[l];
            if(ai>=n||aj>=m||ai<0||aj<0)continue;
            if(s[ai].charAt(aj)=='B')
            return;
        }
        if(s[i].charAt(j)=='G')
          count++;
          
         for(int l=0;l<4;l++){
             DFS(s,visited,i+r[l],j+c[l],n,m);
         }
    }
    
	public static void main (String[] args) throws java.lang.Exception
	{
	   // Scanner sc=new Scanner(System.in);
	    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	    //int t=1;
	    //t=sc.nextInt();
	    int t=Integer.parseInt(br.readLine());
	    while(--t>=0){
	        count=0;
	        int c=0;
	       StringTokenizer st=new StringTokenizer(br.readLine());
	        int n=Integer.parseInt(st.nextToken());
	        int m=Integer.parseInt(st.nextToken());
	        String s[]=new String[n];
	        for(int i=0;i<n;i++)s[i]=br.readLine();
	        for(int i=0;i<n;i++){
	            for(int j=0;j<m;j++){
	                if(s[i].charAt(j)=='G')
	                c++;
	            }
	        }
	        
	        boolean visited[][]=new boolean[n][m];
	        DFS(s,visited,n-1,m-1,n,m);
	        if(c==count)System.out.println("Yes");
	        else System.out.println("No");
	     
	        
	    }
	    
	}
}