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

typedef long long ll;

void dfs(vector<vector<char> > &a, ll i, ll j, vector<vector<bool> > &visited, bool &ans)
{
    // cout<<i<<" "<<j<<endl;    
    
    visited[i][j] = true;
    
    ll n = a.size();
    ll m = a[0].size();
    
    // cout<<"kk1"<<endl;
    if(i== n-1 && j == m-1)
    {
        ans = true;
        return;
    }
    
    // cout<<"kk2"<<endl;
    if(i-1>=0 && a[i-1][j] != '#' && !visited[i-1][j])
    {
        dfs(a, i-1, j, visited, ans);
        if(ans)
            return;
        
    }
    // cout<<"kk3"<<endl;
    if(i+1<n && a[i+1][j] != '#' && !visited[i+1][j])
    {    
        dfs(a, i+1, j, visited, ans);
        if(ans)
            return;
    }
    // cout<<"kk4"<<endl;
    if(j-1>=0 && a[i][j-1] != '#' && !visited[i][j-1])
    {
        dfs(a, i, j-1, visited, ans);
        if(ans)
            return;
    }
    // cout<<"kk5"<<endl;
    if(j+1<m && a[i][j+1] != '#' && !visited[i][j+1])
    {    
        dfs(a, i, j+1, visited, ans);
        if(ans)
            return;
    }
    
    // cout<<"kk6"<<endl;
    
    if(ans)
        return;
}

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        
        ll n, m;
        cin>>n>>m;
        
        vector<vector<char> > a(n, vector<char> (m, 'a'));
        
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<m; j++)
            {
                cin>>a[i][j];
            }
        }
        
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<m; j++)
            {
                if(a[i][j] == '.')
                {
                    if(i-1>=0 && a[i-1][j] == 'B')
                        a[i][j] = '#';
                    else if(i+1<n && a[i-1][j] == 'B')
                        a[i][j] == '#';
                    else if(j-1>=0 && a[i][j-1] == 'B')
                        a[i][j] == '#';
                    else if(j+1<m && a[i][j+1] == 'B')
                        a[i][j] == '#';
                }
            }
        }
        
        bool ans = true;
    
        
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<m; j++)
            {
                if(a[i][j] == 'G')
                {
                    vector<vector<bool> > visited(n, vector<bool> (m, false)); 
                    bool curAns = false;
                    
                    dfs(a, i, j, visited, curAns);
                    
                    if(!curAns)
                    {
                        ans = false;
                        break;
                    }
                }        
            }
            
            if(!ans)
                break;
        }
        
        if(ans)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        
    }
}