#include <bits/stdc++.h>
using namespace std;
char maps[60][60] = {0};
bool flg[60][60];
int n, m;
int num;
void dfs(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > m) return;
  if (maps[x][y] == '#') return;
  if (flg[x][y] == 1) return;
  if (maps[x][y] == 'G') num++;
  flg[x][y] = 1;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
void dfss(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > m) return;
  if (maps[x][y] == '#') return;
  if (flg[x][y] == 1) return;
  if (maps[x][y] == 'B') num++;
  flg[x][y] = 1;
  dfss(x + 1, y);
  dfss(x - 1, y);
  dfss(x, y + 1);
  dfss(x, y - 1);
}
int main() {
  int i, j, k, l, t, r, rr;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    scanf("%d", &m);
    r = 0;
    for (i = 1; i <= n; i++) {
      scanf("%s", maps[i] + 1);
      for (j = 1; j <= m; j++) {
        if (maps[i][j] == 'G') r++;
      }
    }
    memset(flg, 0, sizeof flg);
    num = 0;
    dfs(n, m);
    if (num < r) {
      printf("No\n");
      continue;
    }
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) {
        if (maps[i][j] == '.') {
          maps[i][j] = '#';
          memset(flg, 0, sizeof flg);
          num = 0;
          dfs(n, m);
          if (num < r) maps[i][j] = '.';
        }
      }
    memset(flg, 0, sizeof flg);
    num = 0;
    dfss(n, m);
    if (num > 0)
      printf("No\n");
    else
      printf("Yes\n");
  }
  return 0;
}
