#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int n = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = n * 10 + ch - '0';
    ch = getchar();
  }
  return n * f;
}
char str[101][101];
int vis[101][101];
int t, n, m;
int dfs(int i, int j) {
  if (i < 0 || i > n || j < 0 || j > m) return -1;
  if (str[i][j] == 'W') return -1;
  if (i == n && j == m) return 1;
  if (vis[i][j] != 0) return vis[i][j];
  vis[i][j] = -1;
  if (dfs(i, j + 1) == 1) return vis[i][j] = 1;
  if (dfs(i, j - 1) == 1) return vis[i][j] = 1;
  if (dfs(i + 1, j) == 1) return vis[i][j] = 1;
  if (dfs(i - 1, j) == 1) return vis[i][j] = 1;
  return vis[i][j] = -1;
}
int main() {
  bool flag;
  t = read();
  for (int greg = 1; greg <= t; greg++) {
    n = read();
    m = read();
    for (int i = 0; i <= n + 1; i++)
      for (int j = 0; j <= m + 1; j++) str[i][j] = 'W';
    for (int i = 1; i <= n; i++) scanf("%s", str[i] + 1);
    flag = false;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (str[i][j] == 'B') {
          if (str[i - 1][j] == 'G' || str[i + 1][j] == 'G' ||
              str[i][j - 1] == 'G' || str[i][j + 1] == 'G') {
            printf("No\n");
            flag = true;
            break;
          }
          str[i - 1][j] = 'W';
          str[i + 1][j] = 'W';
          str[i][j - 1] = 'W';
          str[i][j + 1] = 'W';
        }
      }
      if (flag == true) break;
    }
    if (flag == true) continue;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) vis[i][j] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (str[i][j] == 'G' && dfs(i, j) == -1) {
          printf("No\n");
          flag = true;
          break;
        }
      }
      if (flag == true) break;
    }
    if (flag == false) {
      printf("Yes\n");
    }
  }
  return 0;
}
