#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef vector<ppi> vppi;
typedef map<int,int> mii;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
const int mod=1e9+7;
#define ZERO(a) memset(a,0,sizeof(a))
#define Acc(i,n,a) for(int i=0;i<(int)n;i++) cin>>a[i]
#define Debug(i,n,a) For(i,n) cout<<a[i]<<" ";cout<<endl;
int MPOW( int a, int b, int m) { if(b==0) return 1; int x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
int MINV( int a, int m) { return MPOW(a,m-2,m);}
int MFACT( int n, int m){ if(m<=n) return 0; else if(n==0) return 1; else return ((MFACT(n-1,m)*n)%m);}
int b[55][55];
set<pair<int, int>> al;

int isSafe(int row, int col, int ROW , int COL) 
{ 
    return (row >= 0) && (row < ROW) && (col >= 0) && (col < COL) ; 
} 
int dfs(vpi& gd, int x, int y, int n, int m){
	b[x][y]=1;
	int ans=0;
	if(al.count({x,y})==1)
		ans++;
	if(isSafe(x+1, y, n,m) && b[x+1][y]==0){
		ans+=dfs(gd, x+1, y, n, m);
	}
	if(isSafe(x-1, y, n,m) && b[x-1][y]==0){
		ans+=dfs(gd, x-1, y, n, m);
	}
	if(isSafe(x, y+1, n,m) && b[x][y+1]==0){
		ans+=dfs(gd, x, y+1, n, m);
	}
	if(isSafe(x, y-1, n,m) && b[x][y-1]==0){
		ans+=dfs(gd, x, y-1, n, m);
	}
	return ans;
}
void solve()
{
	cout<<fixed;
	cout<<setprecision(0);
	int n,m,k;
	cin>>n>>m;
	string a[n];
	Acc(i,n,a);

	int bc=0, gc=0;
	vpi gd, bd;
	ZERO(b);
	For(i,n){
		For(j,m){
			if(a[i][j]=='G'){
				gc++;
				gd.pb({i,j});
				al.insert({i,j});
			}
			else if(a[i][j]=='B'){
				bc++;
				bd.pb({i,j});
			}
			else if(a[i][j]=='#')
				b[i][j]=1;
		}
	}
	if(gc==0)
		d1("Yes");
	else{
		For(i,gd.size()){
			For(j,bd.size()){
				if(abs(gd[i].F-bd[i].F)+abs(gd[i].S-bd[i].S)==1){
					d1("No");
					return;
				}
				else if(abs(n-1-bd[i].F)+abs(m-1-bd[i].S)==1){
					d1("No");
					return;
				}
			}
		}
		if(dfs(gd, n-1, m-1, n, m)==gc){
			d1("Yes");
			return;
		}
		d1("No");		
	}
}
main()
{
	fio;
	int T=1;
	cin>>T;
	while(T--)
		solve();
	return 0;
}