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