import java.util.Scanner;

public class CF1365D
{	
	static boolean possible=true;
	
	public static void main(String[] args)
	{	
		Scanner sc = new Scanner(System.in);
		
		int testCases = sc.nextInt();
		
		for(int testCaseNo=1 ; testCaseNo<=testCases ; testCaseNo++)
		{
			int rows = sc.nextInt();
			int cols = sc.nextInt();
			
			char maze[][] = new char[rows][cols];
			
			for(int rowNo=0 ; rowNo<rows ; rowNo++)
			{
				maze[rowNo]=sc.next().toCharArray();
			}
			
			for(int rowNo=0; rowNo<rows ; rowNo++)
			{
				for(int colNo=0; colNo<cols ; colNo++)
				{
					if( maze[rowNo][colNo]=='B')
					{
						if(colNo-1>=0&&maze[rowNo][colNo-1]=='.')
						{
							maze[rowNo][colNo-1]='#'; //left cell
						}
						
						if(colNo+1<cols&&maze[rowNo][colNo+1]=='.')
						{
							maze[rowNo][colNo+1]='#'; //right cell
						}
						
						if(rowNo-1>=0&&maze[rowNo-1][colNo]=='.')
						{
							maze[rowNo-1][colNo]='#'; //up
						}
						
						if(rowNo+1<rows&&maze[rowNo+1][colNo]=='.')
						{
							maze[rowNo+1][colNo]='#'; //down
						}
					}
				}
			}
			
			possible = true;
			if(maze[rows-1][cols-1]=='.')
			{	
				dfs(rows-1,cols-1,maze); 
			
			}
			
			loop:for(int rowNo=rows-1; rowNo>=0 ; rowNo--)
			{
				for(int colNo=cols-1; colNo>=0; colNo--)
				{
					  if(maze[rowNo][colNo]=='G')
					  {    
						  possible=false;
						  break loop;
					  }
					  
				}
			}
			
			if(possible)
			{
				System.out.println("yes");
			}else 
			{
				System.out.println("No");
			}
			
			
		}
	}

	private static void dfs(int rowNo, int colNo, char[][] maze)
	{
		if(rowNo>=0&&rowNo<maze.length&&colNo>=0&&colNo<maze[0].length)
		{	
			if(maze[rowNo][colNo]!='#'&&maze[rowNo][colNo]!='$'&&maze[rowNo][colNo]!='B')
			{	
				maze[rowNo][colNo]='$';
				dfs(rowNo-1,colNo,maze);
				dfs(rowNo+1,colNo,maze);
				dfs(rowNo,colNo+1,maze);
				dfs(rowNo,colNo-1,maze);
			}
			
			if(maze[rowNo][colNo]=='B')
			{
				possible=false;
			}
		
		}
		
	}
}
