//
// Created by watemus on 07.06.2020.
//
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;

template<typename T>
using vec = vector<T>;

template<typename T>
using uset = unordered_set<T>;

template<typename T1, typename T2>
using umap = unordered_map<T1, T2>;

#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
constexpr ld PI = acos(-1);

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

void run() {
    int n, m;
    cin >> n >> m;
    int cntg = 0;
    vec<vec<char>> f(n + 2, vec<char>(m + 2, '#'));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> f[i][j];
            cntg += (f[i][j] == 'G');
        }
    }
    f[n][m] = 'G';
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (f[i][j] == 'B') {
                for (auto [di, dj] : DD) {
                    if (f[i+di][j+dj] == 'G' && cntg > 0) {
                        cout << "No\n";
                        return;
                    }
                    f[i+di][j+dj] = '#';
                }
            }
        }
    }
    queue<pair<int, int>> q;
    vec<vec<int>> usd(n + 2, vec<int>(m + 2));
    usd[n][m] = 1;
    q.push({n, m});
    while (q.size()) {
        auto [x, y] = q.front();
        q.pop();
        for (auto [dx, dy] : DD) {
            if (f[x+dx][y+dy] != '#' && !usd[x+dx][y+dy]) {
                usd[x+dx][y+dy] = 1;
                q.push({x+dx,y+dy});
            }
        }
    }
    for (int i = 1;i <= n; i++) {
        for (int j = 1; j<= m;j++) {
            if (!usd[i][j] && f[i][j] == 'G') {
                cout << "No\n";
                return;
            }
        }
    }
    cout << "Yes\n";
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    cout << fixed << setprecision(20);
    int t = 1;
   cin >> t;
    while (t--) {
        run();
    }
    return 0;
}


