#include <bits/stdc++.h>
using namespace std;
const int N = 50;
char matrix[N][N];
bool reach[N][N];
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) cin >> matrix[i][j];
    bool alpha = true;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (matrix[i][j] == 'B') {
          if (i > 0) {
            if (matrix[i - 1][j] == 'G')
              alpha = false;
            else if (matrix[i - 1][j] != 'B')
              matrix[i - 1][j] = '#';
          }
          if (i < n - 1) {
            if (matrix[i + 1][j] == 'G')
              alpha = false;
            else if (matrix[i + 1][j] != 'B')
              matrix[i + 1][j] = '#';
          }
          if (j > 0) {
            if (matrix[i][j - 1] == 'G')
              alpha = false;
            else if (matrix[i][j - 1] != 'B')
              matrix[i][j - 1] = '#';
          }
          if (j < m - 1) {
            if (matrix[i][j + 1] == 'G')
              alpha = false;
            else if (matrix[i][j + 1] != 'B')
              matrix[i][j + 1] = '#';
          }
        }
      }
    }
    if (!alpha) {
      cout << "No" << '\n';
    } else {
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) reach[i][j] = false;
      queue<pair<int, int>> q;
      q.push({n - 1, m - 1});
      while (!q.empty()) {
        auto [i, j] = q.front();
        q.pop();
        if (reach[i][j] || matrix[i][j] == '#' || i < 0 || i > n - 1 || j < 0 ||
            j > m - 1)
          continue;
        else
          reach[i][j] = true;
        q.push({i - 1, j});
        q.push({i + 1, j});
        q.push({i, j - 1});
        q.push({i, j + 1});
      }
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
          if (matrix[i][j] == 'G' && !reach[i][j]) alpha = false;
      cout << (alpha ? "Yes" : "No") << '\n';
    }
  }
  return 0;
}
