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