#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    char s[n][m];
    bool b[n][m];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; ++j) {
        cin >> s[i][j];
        b[i][j] = 0;
      }
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        if (s[i][j] == 'B') {
          if (i > 0) {
            if (s[i - 1][j] == 'G') {
              cout << "No\n";
              goto sos;
            } else if (s[i - 1][j] != 'B')
              s[i - 1][j] = '#';
          }
          if (j > 0) {
            if (s[i][j - 1] == 'G') {
              cout << "No\n";
              goto sos;
            } else if (s[i][j - 1] != 'B')
              s[i][j - 1] = '#';
          }
          if (i < n - 1) {
            if (s[i + 1][j] == 'G') {
              cout << "No\n";
              goto sos;
            } else if (s[i + 1][j] != 'B')
              s[i + 1][j] = '#';
          }
          if (j < m - 1) {
            if (s[i][j + 1] == 'G') {
              cout << "No\n";
              goto sos;
            } else if (s[i][j + 1] != 'B')
              s[i][j + 1] = '#';
          }
        }
      }
    goto dod;
  sos : { continue; }
  dod : {}
    queue<pair<int, int> > q;
    if (s[n - 1][m - 1] == '.') {
      q.push({n - 1, m - 1});
      b[n - 1][m - 1] = 1;
    }
    while (!q.empty()) {
      auto pa = q.front();
      q.pop();
      int i = pa.first, j = pa.second;
      if (i > 0) {
        if (s[i - 1][j] != '#' && !b[i - 1][j]) {
          b[i - 1][j] = 1;
          q.push({i - 1, j});
        }
      }
      if (j > 0) {
        if (s[i][j - 1] != '#' && !b[i][j - 1]) {
          b[i][j - 1] = 1;
          q.push({i, j - 1});
        }
      }
      if (i < n - 1) {
        if (s[i + 1][j] != '#' && !b[i + 1][j]) {
          b[i + 1][j] = 1;
          q.push({i + 1, j});
        }
      }
      if (j < m - 1) {
        if (s[i][j + 1] != '#' && !b[i][j + 1]) {
          b[i][j + 1] = 1;
          q.push({i, j + 1});
        }
      }
    }
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        if (s[i][j] == 'G' && !b[i][j]) {
          cout << "No\n";
          goto sos1;
        }
      }
    cout << "Yes\n";
  sos1 : {}
  }
}
