#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" : "<<x<<'\n';
#define int long long
#define PI 3.141592653589793238

void dfs_on_mat(vector<string>& maze,bool**visited,int row,int col){
	if(maze[row][col]=='#' || maze[row][col]=='B')
		return;
	visited[row][col] = true;
	if(row-1>=0 && (maze[row-1][col]=='.' || maze[row-1][col]=='G') && visited[row-1][col]==false){
		dfs_on_mat(maze,visited,row-1,col);
	}
	if(col-1>=0 && (maze[row][col-1]=='.' || maze[row][col-1]=='G') && visited[row][col-1]==false){
		dfs_on_mat(maze,visited,row,col-1);
	}
}

void solve()
{
	int n,m; cin>>n>>m;
	vector<string> maze(n);
	for(int i=0;i<n;i++){
		cin>>maze[i];
	}
	bool have_g = false;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			bool flag = true;
			if(maze[i][j]=='B'){//should be isolated;
				if(i+1<n && maze[i+1][j]=='G')
					flag = false;
				else if(i+1<n)
					maze[i+1][j]='#';
				if(j+1<m && maze[i][j+1]=='G')
					flag = false;
				else if(j+1<m)
					maze[i][j+1]='#';
				if(i-1>=0 && maze[i-1][j]=='G')
					flag = false;
				else if(i-1>=0)
					maze[i-1][j]='#';
				if(j-1>=0 && maze[i][j-1]=='G')
					flag = false;
				else if(j-1>=0)
					maze[i][j-1]='#';
			}
			else if(maze[i][j]=='G'){
				have_g = true;
			}
			if(!flag){
				// cout<<"1  ";
				cout<<"No\n";
				return;
			}
		}
	}
	if(!have_g){
		// cout<<"2  ";
		cout<<"Yes\n";
		return;
	}
	bool **visited = new bool*[n];
	for(int i=0;i<n;i++){
		visited[i] = new bool [m];
		for(int j=0;j<m;j++){
			visited[i][j] = false;
		}
	}
	dfs_on_mat(maze,visited,n-1,m-1);

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(maze[i][j]=='G' && visited[i][j]==false){
				// cout<<"3  ";
				cout<<"No\n";
				return;
			}
		}
	}

	// cout<<"4  ";
	cout<<"Yes\n";

}

main()
{
	int t=1; cin>>t;
	while(t--)
		solve();
}