#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define ff first
#define ss second
using namespace std;
ll n,t,m;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>t;
      while(t--){
        cin>>n>>m;
        char a[n][m];
        ll f=0,sum=0;
        for(int i=0;i<n;i++)
        {
          for(int j=0;j<m;j++)
          {
            cin>>a[i][j];
            if(a[i][j]=='G')sum++;
          }
        }
        if(sum==0){cout<<"Yes"<<endl;continue;}
        for(int i=0;i<n;i++)
        {
          for(int j=0;j<m;j++)
          {
            if(a[i][j]=='B'){
              if(i>0&&a[i-1][j]=='.') a[i-1][j]='#';
              if(i<n-1&&a[i+1][j]=='.') a[i+1][j]='#';
              if(j>0&&a[i][j-1]=='.') a[i][j-1]='#';
              if(j<m-1&&a[i][j+1]=='.') a[i][j+1]='#';
              if((i<n-1&&a[i+1][j]=='G')||(i>0&&a[i-1][j]=='G')||(j>0&&a[i][j-1]=='G')||(j<m-1&&a[i][j+1]=='G'))
                f=1;
            }
          }
        }
        if(f==1 || a[n-1][m-1]=='#'){cout<<"No"<<endl; continue;} 
        queue<pair<ll,ll>>q;
        q.push({n-1,m-1});
        ll vis[n][m]={0},cnt=0;
        vis[n-1][m-1]=1;
        while(!q.empty()){
           pair<ll,ll> p=q.front();
           q.pop();
           if(a[p.ff][p.ss]=='G')cnt++;
           ll i=p.ff,j=p.ss;
           if(i>0&&vis[i-1][j]==0) q.push({i-1,j}),vis[i-1][j]=1;
           if(i<n-1&&vis[i+1][j]==0) q.push({i+1,j}),vis[i+1][j]=1;
           if(j>0&&vis[i][j-1]==0) q.push({i,j-1}),vis[i][j-1]=1;
           if(j<m-1&&vis[i][j+1]==0) q.push({i,j+1}),vis[i][j+1]=1;
        }
        if(cnt==sum)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
      } 
}