#include <bits/stdc++.h>
using namespace std;
const int N = 1111111, M = 12222222;
long long MOD = 1e9 + 7;
int intINF = int(1e9);
long long llINF = long long(2e18);
double eps = 1e-8;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
long double pi = acos(-1.0L);
long double s2 = sqrt(2.0);
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
long long readll() {
  long long v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
inline char nc() {
  static char buf[100000], *p1, *p2;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
int rd() {
  int x = 0;
  char ch = nc();
  while (ch < '0' || ch > '9') ch = nc();
  while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = nc();
  return x;
}
struct node {
  int x, y;
} q[55 * 55];
int vis[55][55], flag[55][55], n, m;
char s[55][55];
void predo() {}
void init() {
  n = read(), m = read();
  for (int i = (int)1; i <= (int)n; i++) scanf("%s", s[i] + 1);
}
int isok(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= m); }
void bfs(int x1, int y1) {
  int t = 0, w = 1;
  for (int i = (int)1; i <= (int)n; i++)
    for (int j = (int)1; j <= (int)m; j++) vis[i][j] = 0;
  if (s[x1][y1] == '#') return;
  q[1] = (node){x1, y1};
  vis[x1][y1] = 1;
  while (t < w) {
    node u = q[++t];
    for (int i = (int)0; i <= (int)3; i++) {
      int x = u.x + dx[i], y = u.y + dy[i];
      if (isok(x, y) && s[x][y] != '#' && !vis[x][y]) {
        q[++w] = (node){x, y};
        vis[x][y] = 1;
      }
    }
  }
}
void solve() {
  int s1 = 0, s2 = 0;
  for (int i = (int)1; i <= (int)n; i++)
    for (int j = (int)1; j <= (int)m; j++) {
      if (s[i][j] == 'G') s1++;
      if (s[i][j] == 'B') s2++;
    }
  if (s1 == 0) {
    printf("Yes\n");
    return;
  }
  for (int i = (int)1; i <= (int)n; i++)
    for (int j = (int)1; j <= (int)m; j++)
      if (s[i][j] == 'B') {
        bfs(i, j);
        for (int x = (int)1; x <= (int)n; x++)
          for (int y = (int)1; y <= (int)m; y++) {
            if (isok(x, y) && vis[x][y] && s[x][y] == '.') {
              if (x == n && y == m) continue;
              flag[x][y] = 1;
            }
          }
      }
  for (int i = (int)1; i <= (int)n; i++)
    for (int j = (int)1; j <= (int)m; j++)
      if (flag[i][j]) s[i][j] = '#';
  bfs(n, m);
  for (int i = (int)1; i <= (int)n; i++) {
  }
  for (int i = (int)1; i <= (int)n; i++)
    for (int j = (int)1; j <= (int)m; j++)
      if (s[i][j] == 'G' && !vis[i][j]) {
        printf("No\n");
        return;
      }
  for (int i = (int)1; i <= (int)n; i++)
    for (int j = (int)1; j <= (int)m; j++)
      if (s[i][j] == 'B' && vis[i][j]) {
        printf("No\n");
        return;
      }
  printf("Yes\n");
}
int main() {
  int cas = read();
  predo();
  while (cas--) {
    init();
    solve();
  }
  return 0;
}
