#include <bits/stdc++.h>
long long fpow(long long x, long long y, long long p = 1000000007) {
  x = x % p;
  long long sum = 1;
  while (y) {
    if (y & 1) sum = sum * x;
    sum %= p;
    y = y >> 1;
    x = x * x;
    x %= p;
  }
  return sum;
}
long long fact[1000007] = {0};
void facto() {
  fact[0] = 1;
  fact[1] = 1;
  for (long long i = 2; i < 100007; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
}
long long ncr(long long n, long long r) {
  long long res = 1;
  res = fact[n];
  res = (res * (fpow(fact[r], 1000000007 - 2))) % 1000000007;
  res = (res * (fpow(fact[n - r], 1000000007 - 2))) % 1000000007;
  return res;
}
long long npr(long long n, long long r) {
  long long res = 1;
  res = fact[n];
  res = (res * (fpow(fact[n - r], 1000000007 - 2))) % 1000000007;
  return res;
}
long long modmul(long long x, long long y) { return (x * y) % 1000000007; }
long long modadd(long long x, long long y) { return (x + y) % 1000000007; }
long long modsub(long long x, long long y) {
  return (x - y + 1000000007) % 1000000007;
}
long long xx[4] = {1, 0, -1, 0};
long long yy[4] = {0, 1, 0, -1};
using namespace std;
long long f;
long long n, m;
char a[100][100];
long long vis[100][100];
long long num[100][100];
long long par[10000];
long long find(long long u) {
  if (u == par[u]) return par[u];
  par[u] = find(par[par[u]]);
  return par[u];
}
void unite(long long u, long long v) {
  u = find(u), v = find(v);
  if (u == v) return;
  par[u] = v;
}
long long check(long long x, long long y) {
  if (x < 1 || x > n) return 0;
  if (y < 1 || y > m) return 0;
  return 1;
}
void dfs(long long x, long long y) {
  vis[x][y] = 1;
  if (a[x][y] == '.') {
    a[x][y] = '#';
    return;
  }
  for (long long i = 0; i < 4; i++) {
    if (check(x + xx[i], y + yy[i]) && !vis[x + xx[i]][y + yy[i]] &&
        a[x + xx[i]][y + yy[i]] != '#')
      dfs(x + xx[i], y + yy[i]);
  }
}
void dfs2(long long x, long long y) {
  vis[x][y] = 1;
  if (x == n && y == m) {
    f = 1;
  }
  for (long long i = 0; i < 4; i++) {
    if (check(x + xx[i], y + yy[i]) && !vis[x + xx[i]][y + yy[i]] &&
        a[x + xx[i]][y + yy[i]] != '#')
      dfs2(x + xx[i], y + yy[i]);
  }
}
void solve() {
  cin >> n >> m;
  memset(a, '0', sizeof(a));
  vector<pair<long long, long long> > v2, v1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'G') {
        v1.push_back({i, j});
      } else if (a[i][j] == 'B') {
        v2.push_back({i, j});
      }
    }
  }
  for (long long i = 0; i < v2.size(); i++) {
    dfs(v2[i].first, v2[i].second);
  }
  long long no = 1;
  long long tot = n * n;
  for (long long i = 1; i <= tot; i++) {
    par[i] = i;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      num[i][j] = no++;
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (a[i][j] != '#') {
        long long u = num[i][j];
        for (long long k = 0; k < 4; k++) {
          long long nx = i + xx[k];
          long long ny = j + yy[k];
          if (!check(nx, ny)) continue;
          if (a[nx][ny] == '#') continue;
          long long v = num[nx][ny];
          unite(u, v);
        }
      }
    }
  }
  for (long long i = 0; i < v1.size(); i++) {
    long long x1 = v1[i].first;
    long long y1 = v1[i].second;
    long long x2 = n;
    long long y2 = m;
    long long u = num[x1][y1], v = num[x2][y2];
    u = find(u), v = find(v);
    if (u != v) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) solve();
}
