#include <bits/stdc++.h>
using namespace std;
char grid[55][55];
long long dist[55][55];
long long n, m;
long long dx[] = {1, -1, 0, 0};
long long dy[] = {0, 0, 1, -1};
bool isValid(long long r, long long c) {
  if (r < 1 || c < 1 || r > n || c > m) return false;
  if (grid[r][c] == '#') return false;
  if (grid[r][c] == 'B') return false;
  return true;
}
void dfs(long long r, long long c) {
  if (dist[r][c] == 1) return;
  for (long long i = 0; i <= 3; i++) {
    if (grid[r + dx[i]][c + dy[i]] == 'B') return;
  }
  dist[r][c] = 1;
  for (long long i = 0; i <= 3; i++) {
    long long x = r + dx[i];
    long long y = c + dy[i];
    if (isValid(x, y)) dfs(x, y);
  }
}
int main() {
  long long cs;
  scanf("%lld", &cs);
  while (cs--) {
    for (long long i = 0; i <= 54; i++)
      for (long long j = 0; j <= 54; j++) {
        dist[i][j] = 0;
        grid[i][j] = '\0';
      }
    scanf("%lld", &n);
    scanf("%lld", &m);
    for (long long i = 1; i <= n; i++) scanf(" %s", &grid[i][1]);
    dfs(n, m);
    bool ans = true;
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= m; j++) {
        if (grid[i][j] == 'G' && dist[i][j] == 0) ans = false;
      }
    if (ans)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
