import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class codeforces {
  static char[][] matrix;
  static String[][] color;
  static boolean[][] vis;
  static int n ;
  static int m ;
	public static void main(String[] args) {
			
     scanner in  = new scanner();
     int t = in.nextInt();
     for(int z = 0;z<t;z++)
     {
    	 n = in.nextInt();
    	  m = in.nextInt();
    	 int Gc = 0;
    	 matrix = new char[n][m];
    	 color = new String[n][m];
    	 vis = new boolean[n][m];
    	 boolean no = false;
    	 for(int i = 0;i<n;i++)
    	 {
    		 String s = in.next();
    		 for(int j = 0;j<m;j++)
    		 {
    			 //System.out.println("im here");
    			 matrix[i][j] = s.charAt(j);
    			 if(matrix[i][j]=='G')
    				 Gc++;
    		 }
    	 }
    	 if(Gc==0)
    		 System.out.println("yes");
    	 else
    	 {
    		 for(int i = 0;!no && i<n;i++)
    			 for(int j = 0;!no && j<m;j++)
    			 {
    				 if(matrix[i][j]=='B')
    				 {
    					 if(i>0)
    					 {
    						 if(matrix[i-1][j]=='G')
    							 no = true;
    						 if(matrix[i-1][j]=='.')
    							 matrix[i-1][j] = '#';
    					 }
    					 if(j>0)
    					 {
    						 if(matrix[i][j-1]=='G')
    							 no = true;
    						 if(matrix[i][j-1]=='.')
    							 matrix[i][j-1] = '#';
    					 }
    					 if(i<n-1)
    					 {
    						 if(matrix[i+1][j]=='G')
    							 no = true;
    						 if(matrix[i+1][j]=='.')
    							 matrix[i+1][j] = '#';
    					 }
    					 if(j<m-1)
    					 {
    						 if(matrix[i][j+1]=='G')
    							 no = true;
    						 if(matrix[i][j+1]=='.')
    							 matrix[i][j+1] = '#';
    					 }
    				 }
    			 }
    		 if(no || (matrix[n-1][m-1]=='#' && Gc>0))
        		 System.out.println("no");
        	 else
        	 {
        		 color[n-1][m-1] = "red";
        		 boolean control = true;
        		 for(int i = 0;control && i<n;i++)
        		 {
        		   for(int j = 0;control && j<m;j++)
        		   {
        			  if(matrix[i][j]=='G')
        			  {
        				  if(!vis[i][j])
        				  {
        				       dfs(i,j);
        				       if(color[n-1][m-1]=="red")
        				       {
             					  control = false;
        				       }
        				  }
        			  }
        			  color[n-1][m-1] = "red";
        		   }
        		 }
        		 if(control)
        			 System.out.println("yes");
        		 else
        			 System.out.println("no");
        	 }
    	 }
     }
	}
	public static void dfs(int i,int j)
	{
		vis[i][j] = true;
		if((i==n-1 && j==m-1) || color[i][j]=="green")
		{
			color[n-1][m-1] = "green";
			return;
		}
		if(i>0 && (matrix[i-1][j]=='.' || matrix[i-1][j]=='G' ) && !vis[i-1][j] && color[n-1][m-1]=="red")
		{
			     dfs(i-1,j);
		}
		if(i<n-1 && (matrix[i+1][j]=='.')  && !vis[i+1][j] && color[n-1][m-1]=="red")
		{ 
			     dfs(i+1,j);
		}
		if(j>0 && (matrix[i][j-1]=='.')  && !vis[i][j-1] && color[n-1][m-1]=="red")
		{
			     dfs(i,j-1);
		}
		if(j<m-1 && !vis[i][j+1] && color[n-1][m-1]=="red")
		{ 
			     dfs(i,j+1);
		}
		if(color[n-1][m-1]=="green")
			color[i][j] = "green";
	}
}
class scanner
{
	BufferedReader br ;
	StringTokenizer st;
	
	public scanner()
	{
		br = new BufferedReader(new InputStreamReader(System.in));
		st = null;
	}
	 public String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try {
	                st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }
	public int nextInt()
	{
		return Integer.parseInt(next());
	}
	public long nextLong()
	{
	  return	Long.parseLong(next());
	}
}