// Problem: D. Solve The Maze
// Contest: Codeforces - Codeforces Round #648 (Div. 2)
// URL: https://codeforces.com/contest/1365/problem/D
// Memory Limit: 256 MB
// Time Limit: 1000 ms

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using l = long;
using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vl = vector<long>;
using vll = vector<ll>;

#define mp make_pair
#define f first
#define s second

#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define modinv(a,m) modEx(a,m-2,m)
#define moddiv(a,b,m) (a*modinv(b,m))%m
const ll mod=1e9+7;

/* These template codes have been taken from cp-algorithms */
ll extEuclid(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}
	
	ll x1,y1;
	ll d=extEuclid(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return d;
}

ll modInverse(ll a,ll n){
	ll x,y;
	extEuclid(a,n,x,y);
	return x;
}

ll linearCong(ll a,ll b,ll n){
	ll d=__gcd(a,n);
	
	if(b%d)
		return -1;
	a/=d;b/=d;n/=d;
	ll a_inv=modInverse(a,n);
	ll ans=(b*a_inv)%n;
	if(ans<0)
		ans+=n;
	return ans;
}

void divisors(map<int,int>& d,ll N){
	for(int div : {2,3,5}){
		int cnt=0;
		if(N%div==0){
			while((N%div)==0){
				N/=div;
				cnt++;
			}
			d[div]=cnt;
		}
	}
	static array<int,8> increments = {4,2,4,2,4,6,2,6};
	int i=0;
	for(ll div=7;div*div<=N;div+=increments[i++]){
		if((N%div)==0){
			int cnt=0;
			while((N%div)==0){
				N/=div;
				cnt++;
			}
			d[div]=cnt;
		}
		if(i==8)
			i=0;
	}
	if(N>1)
		d[N]=1;
}

/* Print the string of digits without leading zero */
void norm(string& str){
	bool zero=true;
	
	for(auto& c:str){
		if(c!='0')
			zero=false;
		if(c!='0' || !zero)
			cout<<c;
	}
}

void input(vl& v,int N){
	for(int i=0;i<N;i++){
		cin>>v[i];
	}
}

void solve(vl& v,int N){
	
}

char mat[100][100];
bool vis[100][100];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int T,N,M;

bool flood_fill(){
	stack<pair<int,int>> st;
	st.push({N-1,M-1});
	
	while(!st.empty()){
		int x=st.top().f;
		int y=st.top().s;
		st.pop();
		if(x<0 || x>=N || y<0 || y>=M || vis[x][y])
			continue;
		vis[x][y]=1;
		if(mat[x][y]=='B'){
			for(int i=0;i<4;i++){
				int xx=x+dx[i],yy=y+dy[i];
				if(xx<0 || xx>=N || yy<0 || yy>=M || mat[xx][yy]=='#')
					continue;
				if(mat[xx][yy]=='G')
					return false;
				mat[xx][yy]='#';
				
			}
		}
		
		for(int i=0;i<4;i++){
			st.push({x+dx[i],y+dy[i]});
		}
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(mat[i][j]=='G' && !vis[i][j])
				return false;
		}
	}
	
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    

	cin>>T;
	while(T--){
		cin>>N>>M;
		
		int g=0,b=0;
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++){
				cin>>mat[i][j];
				if(mat[i][j]=='G')
					g++;
				if(mat[i][j]=='B')
					b++;
			}
			
		}
		
		if(mat[N-1][M-1]=='#'){
			cout<<"No\n";
			continue;
		}
				
		// If bad person present we can block the last cell
		if(g==0 && b==0){
			cout<<"Yes\n";
			continue;
		}else if(b==0){
			if(mat[N-1][M-1]!='#')
				cout<<"Yes\n";
			else
				cout<<"No\n";
			continue;
		}else if(g==0){
			if(mat[N-1][M-1]=='B')
				cout<<"No\n";
			else
				cout<<"Yes\n";
			continue;
		}
		
		if((N-1>=0 && M-2>=0 && mat[N-1][M-2]=='B') || (N-2>=0 && M-1>=0 && mat[N-2][M-1]=='B') || (mat[N-1][M-1]=='B')){
			cout<<"No\n";
			continue;
		}
			
		if(flood_fill())
			cout<<"Yes\n";
		else
			cout<<"No\n";
		
	}
	
	return 0;	
}
