#include <bits/stdc++.h>
using namespace std;

using ll = long long int;
typedef pair<ll,ll> pll;
using ld = long double;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest element(0-based)=> cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X => cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
string mat[60];
void block(ll r,ll c)
{
	if(mat[r-1][c]!='G')mat[r-1][c]='#';
	if(mat[r+1][c]!='G')mat[r+1][c]='#';
	if(mat[r][c-1]!='G')mat[r][c-1]='#';
	if(mat[r][c+1]!='G')mat[r][c+1]='#';
}
bool path_exists(ll r,ll c,ll n,ll m)
{
	deque<pll> dq;
	dq.pb(mp(r,c));
	multiset<pll> vis;
	while(!dq.empty())
	{
		pll cur=dq.front();
		dq.pop_front();
		if(vis.find(cur)!=vis.end())continue;
		if(cur.f==n and cur.s==m)
			return 1;
		vis.insert(cur);
		if(mat[cur.f-1][cur.s]!='#')dq.pb(mp(cur.f-1,cur.s));
		if(mat[cur.f+1][cur.s]!='#')dq.pb(mp(cur.f+1,cur.s));
		if(mat[cur.f][cur.s-1]!='#')dq.pb(mp(cur.f,cur.s-1));
		if(mat[cur.f][cur.s+1]!='#')dq.pb(mp(cur.f,cur.s+1));
	}
	return 0;
}
int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL);
	// cout.tie(NULL);
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		string s;
		ll g=0,b=0;
		string k="";
		for(ll i=0;i<=m+1;i++)k+="#";
		mat[0]=mat[n+1]=k;
		for(ll i=1;i<=n;i++)
		{
			cin>>s;
			mat[i]="#"+s+"#";
			for(auto it:s)g+=it=='G',b+=it=='B';
		}
		if(mat[n][m]=='B')
		{
			cout<<"No\n";
			continue;
		}
		ll nvm=0;
		for(ll i=1;i<=n;i++)
			for(ll j=1;j<=m;j++)
				if(mat[i][j]=='B')
				{
					nvm|=(mat[i-1][j]=='G' or mat[i+1][j]=='G' or mat[i][j-1]=='G' or mat[i][j+1]=='G');
					if(nvm)break;
					if(path_exists(i,j,n,m))block(i,j);
				}
		if(nvm)
		{
			cout<<"No\n";
			continue;
		}
		if(!g)
		{
			cout<<"Yes\n";
			continue;
		}
		bool f=1;
		for(ll i=1;i<=n;i++)
			for(ll j=1;j<=m;j++)
				if(mat[i][j]=='G' and !path_exists(i,j,n,m))
				{
					f=0;
					break;
				}
		cout<<(f?"Yes":"No")<<"\n";
	}
	return 0;
}