#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[55][55];
bool vis[55][55], ck;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
bool check(long long xx, long long yy) {
  return xx >= 1 and xx <= n and yy >= 1 and yy <= m;
}
void dfs(long long x, long long y) {
  if (x == n and y == m and s[x][y] != '#') {
    ck = 1;
    return;
  }
  if (vis[x][y]) return;
  vis[x][y] = 1;
  for (long long k = 0; k < 4; k++) {
    long long fx = x + dx[k];
    long long fy = y + dy[k];
    if (check(fx, fy) and s[fx][fy] != 'B' and s[fx][fy] != '#') {
      dfs(fx, fy);
    }
  }
}
int main() {
  int tc;
  scanf("%d", &tc);
  for (long long cs = 1; cs <= tc; ++cs) {
    scanf("%d", &n), scanf("%d", &m);
    for (int i = 1; i <= n; i++) {
      for (long long j = 1; j <= m; j++) {
        scanf(" %c", &s[i][j]);
      }
    }
    bool ok = 1;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (s[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int fx = i + dx[k];
            int fy = j + dy[k];
            if (check(fx, fy) and s[fx][fy] == 'G') {
              ok = 0;
            } else if (check(fx, fy) and s[fx][fy] == '.') {
              s[fx][fy] = '#';
            }
          }
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (s[i][j] == 'G' and !vis[i][j]) {
          ck = 0;
          dfs(i, j);
          ok = ok & ck;
        }
      }
    }
    if (!ok) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  }
  return 0;
}
