/* 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 mazeT
{
	public static void main (String[] args) throws java.lang.Exception
	{
		
		Scanner sc=new Scanner(System.in);
		int t,n,m;
		t=sc.nextInt();
		while(t-->0){
		    n=sc.nextInt();
		    m=sc.nextInt();
		    int i,j;char maze[][]=new char[n][m];
		    for(i=0;i<n;i++){
		        String inp=sc.next();
		       // System.out.println(inp);
		        for(j=0;j<m;j++){
		            char ch=inp.charAt(j);
		            maze[i][j]=ch;
		        }
		    }
		    boolean path[][]=new boolean[n][m];
		    path[n-1][m-1]=true;
		   
		    if(!isPath(maze,path,n,m))
		      System.out.println("No");
		    else{
		        for(i=0;i<n;i++){
		        for(j=0;j<m;j++){
		            if(maze[i][j]=='B')
		                  setFirstWall(path,maze,n,m,i,j);
		        }
		       }
		       path=new boolean[n][m];
		       path[n-1][m-1]=true;
		       //printMaze(maze,n,m);
		      if(isPath(maze,path,n,m))
		       System.out.println("Yes");
		       else
		       System.out.println("No");
		    }
		}
	}
	static void printMaze(char maze[][],int n,int m){
	    int i,j;
	    for(i=0;i<n;i++){
	        for(j=0;j<m;j++){
	            System.out.print(maze[i][j]+" ");
	        }
	        System.out.println();
	    }
	}
    static void setFirstWall(boolean path[][],char ch[][],int n,int m,int i,int j){
        
       // System.out.println("In : "+i+","+j);
        int a[]={0,1,0,-1};
        int b[]={1,0,-1,0};
        int k;int x,y;
        for(k=0;k<4;k++){
            x=i+a[k];y=j+b[k];
        if(x>=0&&x<n&&y>=0&&y<m){
            
            if(!(x==i&&y==j)&&path[x][y]==true){
                path[x][y]=false;
                if(ch[x][y]=='#'||ch[x][y]=='.')
                   ch[x][y]='#';
                else
                  setFirstWall(path,ch,n,m,x,y);
            }
            
        }
        }
        
    }
    static	boolean  isPath(char ch[][],boolean path[][],int n,int m){
	    int i,j;int f=1;
	     for(i=n-1;i>=0;i--){
		        for(j=m-1;j>=0;j--){
		            if(ch[i][j]=='#')
		               path[i][j]=false;
		            else{
		                
		                if(j+1<m)
		                path[i][j]=path[i][j+1];
		                if(i+1<n)
		                 path[i][j]=path[i][j]||path[i+1][j];
		            }
		        }
		    }
		    for(i=0;i<n;i++){
		        for(j=0;j<m;j++){
		            if(i-1>=0)
		            path[i][j]=path[i][j]||path[i-1][j];
		            if(j-1>=0)
		            path[i][j]=path[i][j]||path[i][j-1];
		            if(ch[i][j]=='G'&&path[i][j]==false)
		              {f=0;break;}
		        }
		         if(f==0)break;
		    }
		  if(f==0)
		   return false;
		  return true;
	}
}
