#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void wri(long long x) {
  write(x);
  putchar(' ');
}
const int maxn = 66;
int n, m;
char a[maxn][maxn];
bool b[maxn][maxn], v[maxn][maxn];
void dfs(int x, int y) {
  if (v[x][y] || b[x][y]) return;
  v[x][y] = 1;
  if (x > 1) dfs(x - 1, y);
  if (x < n) dfs(x + 1, y);
  if (y > 1) dfs(x, y - 1);
  if (y < m) dfs(x, y + 1);
}
void solve() {
  n = read(), m = read();
  for (int i = (1); i <= int(n); ++i) scanf("%s", a[i] + 1);
  for (int i = (1); i <= int(n); ++i)
    for (int j = (1); j <= int(m); ++j) b[i][j] = v[i][j] = 0;
  for (int i = (1); i <= int(n); ++i)
    for (int j = (1); j <= int(m); ++j)
      if (a[i][j] == '#') b[i][j] = 1;
  for (int i = (1); i <= int(n); ++i)
    for (int j = (1); j <= int(m); ++j)
      if (a[i][j] == 'B')
        b[i][j] = b[i - 1][j] = b[i + 1][j] = b[i][j - 1] = b[i][j + 1] = 1;
  dfs(n, m);
  for (int i = (1); i <= int(n); ++i)
    for (int j = (1); j <= int(m); ++j)
      if (a[i][j] == 'G' && !v[i][j]) {
        puts("No");
        return;
      }
  puts("Yes");
}
int main() {
  int T = read();
  while (T--) solve();
  return 0;
}
