import java.util.*;
import java.io.*;
 
public class Solution{
	static PrintWriter out=new PrintWriter(System.out);
	public static void main (String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String[] input=br.readLine().trim().split(" ");
		int numTestCases=Integer.parseInt(input[0]);
		
		while(numTestCases-->0) {
			input=br.readLine().trim().split(" ");
			int n=Integer.parseInt(input[0]);
			int m=Integer.parseInt(input[1]);
			char[][] arr=new char[n][m];
			for(int i=0;i<n;i++) {
				input=br.readLine().trim().split(" ");
				for(int j=0;j<m;j++) {
					arr[i][j]=input[0].charAt(j);
				}
			}
			out.println(isPossible(arr));
		}
		
		out.flush();
		out.close();
	}
	public static String isPossible(char[][] arr)
	{
		int n=arr.length;
		int m=arr[0].length;
		int numGood=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]=='B')
				{
					if(i-1>=0 && arr[i-1][j]=='G')
					{
						return "No";
					}
					if(j+1<m && arr[i][j+1]=='G')
					{
						return "No";
					}
					if(i+1<n && arr[i+1][j]=='G')
					{
						return "No";
					}
					if(j-1>=0 && arr[i][j-1]=='G')
					{
						return "No";
					}
					
					if(i-1>=0 && arr[i-1][j]=='.')
					{
						arr[i-1][j]='#';
					}
					if(j+1<m && arr[i][j+1]=='.')
					{
						arr[i][j+1]='#';
					}
					if(i+1<n && arr[i+1][j]=='.')
					{
						arr[i+1][j]='#';
					}
					if(j-1>=0 && arr[i][j-1]=='.')
					{
						arr[i][j-1]='#';
					}
				}
				else if(arr[i][j]=='G'){
					numGood++;
				}
			}
		}
		if(numGood==0) {
			return "Yes";
		}
		if(arr[n-1][m-1]=='#')
		{
			return "No";
		}
		boolean[][] visited=new boolean[n][m];
		int numGoodCovered=dfs(arr,n-1,m-1,visited);
		if(numGoodCovered==numGood)
		{
			return "Yes";
		}
		else {
			return "No";
		}
	}
	public static int dfs(char[][] arr,int row,int col,boolean[][] visited)
	{
		if(row<0 || col<0 || row==arr.length || col==arr[0].length)
		{
			return 0;
		}
		if(visited[row][col])
		{
			return 0;
		}
		if(arr[row][col]=='#')
		{
			return 0;
		}
		visited[row][col]=true;
		int ans=0;
		ans+=dfs(arr,row-1,col,visited);
		ans+=dfs(arr,row,col+1,visited);
		ans+=dfs(arr, row+1, col, visited);
		ans+=dfs(arr, row, col-1, visited);
		if(arr[row][col]=='G')
		{
			ans++;
		}
		return ans;
	}
}