#include <bits/stdc++.h>
using namespace std;
const char NL = '\n';
const long long int MX = 55;
long long int n, m;
char mat[55][55];
bool visited[MX][MX];
void dfs(long long int i, long long int j) {
  if (i >= n || i < 0 || j >= m || j < 0 || mat[i][j] == '#' || visited[i][j])
    return;
  visited[i][j] = 1;
  if (mat[i][j] == '.') {
    mat[i][j] = '#';
    return;
  }
  dfs(i - 1, j);
  dfs(i + 1, j);
  dfs(i, j - 1);
  dfs(i, j + 1);
}
void gdfs(long long int i, long long int j) {
  if (i >= n || i < 0 || j >= m || j < 0 || mat[i][j] == '#' || visited[i][j])
    return;
  visited[i][j] = 1;
  gdfs(i - 1, j);
  gdfs(i + 1, j);
  gdfs(i, j - 1);
  gdfs(i, j + 1);
}
void solve() {
  bool valid = 1;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (mat[i][j] == 'B') {
        memset(visited, 0, sizeof(visited));
        dfs(i, j);
        if (mat[n - 1][m - 1] == '#') valid = false;
      }
    }
    if (!valid) break;
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (mat[i][j] == 'G') {
        memset(visited, 0, sizeof(visited));
        gdfs(i, j);
        if (!visited[n - 1][m - 1]) {
          cout << "No" << NL;
          return;
        }
      }
    }
    if (!valid) break;
  }
  cout << "Yes" << NL;
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        cin >> mat[i][j];
      }
    }
    solve();
  }
  fflush(stdin);
  fflush(stdout);
  return 0;
}
