#include <bits/stdc++.h>
using namespace std;
int T, n, m, dx[5] = {0, 0, -1, 1}, dy[5] = {1, -1, 0, 0}, book[60][60];
char s[60][60];
queue<pair<int, int> > q;
bool bfs(int cnt) {
  while (!q.empty()) q.pop();
  memset(book, 0, sizeof(book));
  int x = n - 1, y = m - 1, cur = 0;
  book[x][y] = 1;
  q.push({x, y});
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    x = p.first;
    y = p.second;
    for (int i = 0; i < 4; i++) {
      int tx = x + dx[i];
      int ty = y + dy[i];
      if (tx >= 0 && tx < n && ty >= 0 && ty < m) {
        if ((s[tx][ty] == '.' || s[tx][ty] == 'G') && !book[tx][ty]) {
          book[tx][ty] = 1;
          q.push({tx, ty});
          if (s[tx][ty] == 'G') cur++;
        }
      }
    }
  }
  return cur == cnt;
}
int main(void) {
  scanf("%d", &T);
  while (T--) {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    int cnt = 0;
    bool can = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] == 'G') cnt++;
        if (s[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int tx = i + dx[k];
            int ty = j + dy[k];
            if (tx >= 0 && tx < n && ty >= 0 && ty < m) {
              if ((tx == n - 1 && ty == m - 1) || s[tx][ty] == 'G') {
                can = false;
              }
              if (s[tx][ty] == '.') s[tx][ty] = '#';
            }
          }
        }
      }
    }
    if (cnt == 0) {
      printf("Yes\n");
      continue;
    }
    if (!can) {
      printf("No\n");
      continue;
    }
    if (bfs(cnt))
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
