#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
int n,m;
int bfs(vector< string > &v){
    int vis[n+1][m+1]={};
    queue <pii> q;
    if(v[n-1][m-1]!='#'){
    vis[n-1][m-1]=1;
    q.push(mp(n-1,m-1));
	}
    while(!q.empty()){
        pii k=q.front();
        int i=k.fi,j=k.se;
        q.pop();
        if((i-1)>=0 && v[i-1][j]!='#' && vis[i-1][j]==0)
		{
			q.push(mp(i-1,j));
			vis[i-1][j]=1;
		}
		if((i+1)<n && v[i+1][j]!='#' && vis[i+1][j]==0)
		{
			q.push(mp(i+1,j));
			vis[i+1][j]=1;
		}
		if((j-1)>=0 && v[i][j-1]!='#' && vis[i][j-1]==0)
		{
			q.push(mp(i,j-1));
			vis[i][j-1]=1;
		}
		if((j+1)<m && v[i][j+1]!='#' && vis[i][j+1]==0)
		{
			q.push(mp(i,j+1));
			vis[i][j+1]=1;
		}
    }
    int u=0;
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		if(v[i][j]=='G' && vis[i][j]==0)
    		u=1;break;
		}
	}
	return u;
}
int main(){
	io;
	int t;
	cin>>t;
	while(t--){
		
		cin>>n>>m;
		vector<string>v(n);
		for(int i=0;i<n;i++)
		cin>>v[i];
		int u=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if((i-1)>=0 && ((v[i][j]=='G' && v[i-1][j]=='B') || (v[i][j]=='B' && v[i-1][j]=='G')))
				u=1;
				if((i+1)<n && ((v[i][j]=='G' && v[i+1][j]=='B') || (v[i][j]=='B' && v[i+1][j]=='G')))
				u=1;
				if((j-1)>=0 && ((v[i][j]=='G' && v[i][j-1]=='B') || (v[i][j]=='B' && v[i][j-1]=='G')))
				u=1;
				if((j+1)<m && ((v[i][j]=='G' && v[i][j+1]=='B') || (v[i][j]=='B' && v[i][j+1]=='G')))
				u=1;
			}
		}
		if(u){
			cout<<"No"<<endl;continue;
		}
		//cout<<11<<endl;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(v[i][j]=='B'){
					if((i-1)>=0 && v[i-1][j]=='.')
					v[i-1][j]='#';
					if((i+1)<n && v[i+1][j]=='.')
					v[i+1][j]='#';
					if((j+1)<m && v[i][j+1]=='.')
					v[i][j+1]='#';
					if((j-1)>=0 && v[i][j-1]=='.')
					v[i][j-1]='#';
				}
			}
		}
		//cout<<11<<endl;
		u=bfs(v);
		if(u==0){
			cout<<"Yes"<<endl;
		}
		else
		cout<<"No"<<endl;
	}
	return 0;
}




