#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using ll = long long;
using vi = vector<int>;
using vell = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vell>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
const int mod = (int)(1e9 + 7);
template <typename A, typename B>
void remin(A& a, const B& b) {
  a = std::min(a, b);
}
template <typename A, typename B>
void remax(A& a, const B& b) {
  a = std::max(a, b);
}
const auto ready = []() {
  cin.tie(0);
  cout.tie(0);
  std::ios_base::sync_with_stdio(false);
  return true;
}();
ll fast_multip(ll a, ll b, ll m) {
  if (!a || !b) return 0;
  if (b == 1) return a;
  if (a == 1) return b;
  if (b % 2 == 0) {
    long long t = fast_multip(a, b / 2, m);
    return (2 * t) % m;
  }
  return (fast_multip(a, b - 1, m) + a) % m;
}
ll fast_pow(ll a, ll b, ll m) {
  if (b == 0) return (m == 1) ? 0 : 1;
  if (b % 2 == 0) {
    ll t = fast_pow(a, b / 2, m);
    return fast_multip(t, t, m) % m;
  }
  return (fast_multip(fast_pow(a, b - 1, m), a, m)) % m;
}
ll inv(ll a) { return fast_pow(a, mod - 2, mod); }
ll gcd(ll a, ll b, ll& x, ll& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  ll x1, y1;
  ll d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vvchar g(n + 2, vchar(m + 2));
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j) cin >> g[i][j];
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        if (g[i][j] == 'B') {
          g[i][j] = '#';
          if (g[i - 1][j] == '.') g[i - 1][j] = '#';
          if (g[i + 1][j] == '.') g[i + 1][j] = '#';
          if (g[i][j - 1] == '.') g[i][j - 1] = '#';
          if (g[i][j + 1] == '.') g[i][j + 1] = '#';
        }
      }
    }
    vvi can(n + 2, vi(m + 2, 0));
    if (g[n][m] != '#') can[n][m] = 1;
    for (int i = n; i > 0; --i) {
      for (int j = m; j > 0; --j) {
        if (can[i][j]) {
          if (g[i - 1][j] != '#') can[i - 1][j] = 1;
          if (g[i + 1][j] != '#') can[i + 1][j] = 1;
          if (g[i][j - 1] != '#') can[i][j - 1] = 1;
          if (g[i][j + 1] != '#') can[i][j + 1] = 1;
        }
      }
    }
    bool ok = true;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j)
        if (g[i][j] == 'G' && !can[i][j]) ok = false;
    cout << ((ok) ? "Yes\n" : "No\n");
  }
  return 0;
}
