#include <bits/stdc++.h>
using namespace std;
int T, n, m, w[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
char mp[55][55];
bool vis[55][55];
void dfs(int x, int y) {
  int i, nx, ny;
  if (vis[x][y] || mp[x][y] == '#') return;
  vis[x][y] = 1;
  for (i = 0; i < 4; i++) {
    nx = x + w[i][0];
    ny = y + w[i][1];
    dfs(nx, ny);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> T;
  int i, j, k, ni, nj;
  while (T--) {
    memset(vis, 0, sizeof(vis));
    memset(mp, 0, sizeof(mp));
    cin >> n >> m;
    for (i = 1; i <= n; i++) cin >> mp[i] + 1;
    for (i = 0; i <= n + 1; i++)
      for (j = 0; j <= m + 1; j++)
        if (!mp[i][j]) mp[i][j] = '#';
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++)
        if (mp[i][j] == 'B')
          for (k = 0; k < 4; k++) {
            ni = i + w[k][0];
            nj = j + w[k][1];
            if (mp[ni][nj] == 'G') {
              cout << "No\n";
              goto over;
            }
            if (mp[ni][nj] != 'B') mp[ni][nj] = '#';
          }
    dfs(n, m);
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++)
        if (mp[i][j] == 'G' && !vis[i][j]) {
          cout << "No\n";
          goto over;
        }
    cout << "Yes\n";
  over:;
  }
  return 0;
}
