#include <bits/stdc++.h>
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define pb push_back
#define ll_MAX 9223372036854775807
#define mp make_pair
#define eb emplace_back
#define lf long double
#define ff first
#define ss second
using namespace std;
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
             tree_order_statistics_node_update> o_set;
 
 
ll expo(ll a,ll b)
{
    if(b==0)
        return 1;
    else if(b%2==0)
    {
        ll y;
        y=expo(a,b/2);
        return (y*y)%M;
    }
    else
        return ((a%M)*expo(a,b-1))%M;
}
ll gc(ll a,ll b)
{
    if(b==0)
        return a;
    else 
        return gc(b,a%b);
}
 
struct compare{
    bool operator()(pair<ll,ll>  a,pair<ll,ll> b)
    {
        if(b.ss-b.ff==a.ss-a.ff)
            return a>=b;
        return a.ss-a.ff<b.ss-b.ff;
    }
};
vector<vector<ll>> anc;
ll lca(ll a,ll b,ll x,ll *level){
    if(level[b]<level[a])
        swap(a,b);
    for(ll j=x;j>=0;j--)
    {
        if(level[anc[b][j]]>=level[a])
            b=anc[b][j];
    }
    if(a==b)
        return a;
    for(ll j=x;j>=0;j--)
    {
        if(anc[a][j]!=anc[b][j])
        {
            a=anc[a][j];
            b=anc[b][j];
        }
    }
    return anc[a][0];
}
ll dfs(vector<ll> *v,ll i,ll *p,bool *vis,ll *level)
{
    vis[i]=1;
    fr(j,0,v[i].size())
    {
        if(!vis[v[i][j]])
        {
            p[v[i][j]]=i;
            level[v[i][j]]=1+level[i];
            dfs(v,v[i][j],p,vis,level);
        }
    }
    return 0;
}
ll dfs2(vector<ll> *v,ll i,bool *vis,ll x)
{
    vis[i]=1;
    for(ll j=1;j<=x;j++)
    {
        anc[i][j]=anc[anc[i][j-1]][j-1];
    }
    fr(j,0,v[i].size())
    {
        if(!vis[v[i][j]])
        {
            dfs2(v,v[i][j],vis,x);
        }
    }
    return 0;
}
struct comp1{
bool operator()(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.ff==b.ff)
        return a.ss<b.ss;
    return a.ff>b.ff;
}
};
struct comp2{
bool operator()(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.ff==b.ff)
        return a.ss>b.ss;
    return a.ff>b.ff;
}
};
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   ll t;
   cin>>t;
   while(t--){
       ll n,m;
       cin>>n>>m;
       string s[n];
       fr(i,0,n)
        cin>>s[i];
        int ch=1;
       fr(i,0,n)
       {
            fr(j,0,m)
            {
                if(s[i][j]=='B')
                {
                    if(j<m-1){
                    if(s[i][j+1]=='.')
                        s[i][j+1]='#';
                    else if(s[i][j+1]=='G'){
                            ch=0;
                            break;
                    }
                    }
                     if(i<n-1){
                    if(s[i+1][j]=='.')
                        s[i+1][j]='#';
                    else if(s[i+1][j]=='G'){
                            ch=0;
                            break;
                    }
                    }
                     if(j>0){
                    if(s[i][j-1]=='.')
                        s[i][j-1]='#';
                    else if(s[i][j-1]=='G'){
                            ch=0;
                            break;
                    }
                    }
                     if(i>0){
                    if(s[i-1][j]=='.')
                        s[i-1][j]='#';
                    else if(s[i-1][j]=='G'){
                            ch=0;
                            break;
                    }
                    }
                }
            }
            if(!ch)
                break;
       }
       if(ch)
       { bool vis[n][m]={0};
           if(s[n-1][m-1]!='#')
           {
               queue<pair<ll,ll>> q;
               q.push({n-1,m-1});
               vis[n-1][m-1]=1;
               while(!q.empty())
               {
                   pair<ll,ll> p;
                   p=q.front();
                   q.pop();
                   ll i=p.ff;
                   ll j=p.ss;
                   if(j<m-1&&s[i][j+1]!='#'&&!vis[i][j+1])
                   {
                        vis[i][j+1]=1;
                        q.emplace(i,j+1);
                   }
                   if(j>0&&s[i][j-11]!='#'&&!vis[i][j-1])
                   {
                        vis[i][j-1]=1;
                        q.emplace(i,j-1);
                   }
                   if(i<n-1&&s[i+1][j]!='#'&&!vis[i+1][j])
                   {
                        vis[i+1][j]=1;
                        q.emplace(i+1,j);
                   }
                   if(i>0&&s[i-1][j]!='#'&&!vis[i-1][j])
                   {
                        vis[i-1][j]=1;
                        q.emplace(i-1,j);
                   }
               }
           }
           for(ll i=0;i<n;i++)
           {
               fr(j,0,m)
               {
                   if(s[i][j]=='G'&&!vis[i][j]){
                        ch=0;
                        break;
                   }
               }
               if(!ch)
                break;
           }
       }
       if(ch)
        cout<<"Yes";
      else
        cout<<"No";
     cout<<"\n";
   }
    return 0;
}