#include <bits/stdc++.h>
using namespace std;
void dfs(int i, int j, int n, int m, char **mat, bool **vis) {
  vis[i][j] = true;
  if (i - 1 >= 0 && mat[i - 1][j] != '#' && vis[i - 1][j])
    dfs(i - 1, j, n, m, mat, vis);
  if (i + 1 < n && mat[i + 1][j] != '#' && vis[i + 1][j])
    dfs(i + 1, j, n, m, mat, vis);
  if (j - 1 >= 0 && mat[i][j - 1] != '#' && vis[i][j - 1])
    dfs(i, j - 1, n, m, mat, vis);
  if (j + 1 < m && mat[i][j + 1] != '#' && vis[i][j + 1])
    dfs(i, j + 1, n, m, mat, vis);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    bool **vis = new bool *[n];
    for (int i = 0; i < n; i++) {
      vis[i] = new bool[m];
      for (int j = 0; j < m; j++) vis[i][j] = false;
    }
    char **mat = new char *[n];
    for (int i = 0; i < n; i++) {
      mat[i] = new char[m];
      for (int j = 0; j < m; j++) cin >> mat[i][j];
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mat[i][j] == 'B') {
          if (i - 1 >= 0 && mat[i - 1][j] == '.') mat[i - 1][j] = '#';
          if (i + 1 < n && mat[i + 1][j] == '.') mat[i + 1][j] = '#';
          if (j - 1 >= 0 && mat[i][j - 1] == '.') mat[i][j - 1] = '#';
          if (j + 1 < m && mat[i][j + 1] == '.') mat[i][j + 1] = '#';
        }
      }
    }
    dfs(n - 1, m - 1, n, m, mat, vis);
    bool poss = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mat[i][j] == 'B' && vis[i][j]) poss = false;
        if (mat[i][j] == 'G' && !vis[i][j]) poss = false;
      }
    }
    if (!poss)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
}
