#include <bits/stdc++.h>
using namespace std;
const int nmax = 55;
int n, m;
char mat[nmax][nmax];
bool visited[nmax][nmax];
void path_for_goodPeople(int l, int c) {
  if (l < 1 || l > n || c < 1 || c > m || mat[l][c] == '#' ||
      visited[l][c] == true)
    return;
  visited[l][c] = true;
  path_for_goodPeople(l - 1, c);
  path_for_goodPeople(l + 1, c);
  path_for_goodPeople(l, c + 1);
  path_for_goodPeople(l, c - 1);
}
int main() {
  int tests;
  cin >> tests;
  while (tests--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> (mat[i] + 1);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (mat[i][j] == 'B') {
          if (i - 1 >= 1 && mat[i - 1][j] == '.') mat[i - 1][j] = '#';
          if (i + 1 <= n && mat[i + 1][j] == '.') mat[i + 1][j] = '#';
          if (j - 1 >= 1 && mat[i][j - 1] == '.') mat[i][j - 1] = '#';
          if (j + 1 <= m && mat[i][j + 1] == '.') mat[i][j + 1] = '#';
        }
    bool ok = true;
    memset(visited, false, sizeof(visited));
    path_for_goodPeople(n, m);
    for (int i = 1; i <= n && ok; i++)
      for (int j = 1; j <= m && ok; j++)
        if (mat[i][j] == 'G' && !visited[i][j])
          ok = false;
        else if (mat[i][j] == 'B' && visited[i][j])
          ok = false;
    if (ok)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
