#include <bits/stdc++.h>
using namespace std;
long long int n, m, mv1[4] = {1, -1, 0, 0};
long long int mv2[4] = {0, 0, 1, -1};
string s[57];
bool flag = true;
int visi[55][55];
bool dfs(long long int i, long long int j) {
  if (i == n and j == m) return 1;
  if (visi[i][j] == 1)
    return 0;
  else if (visi[i][j] == 2)
    return 1;
  else {
    visi[i][j] = 1;
    bool fl = false;
    if (i + 1 <= n and s[i + 1][j] != '#') fl = fl or dfs(i + 1, j);
    if (i - 1 > 0 and s[i - 1][j] != '#') fl = fl or dfs(i - 1, j);
    if (j + 1 <= m and s[i][j + 1] != '#') fl = fl or dfs(i, j + 1);
    if (j - 1 > 0 and s[i][j - 1] != '#') fl = fl or dfs(i, j - 1);
    if (fl)
      visi[i][j] = 2;
    else
      visi[i][j] = 0;
    return visi[i][j];
  }
}
void func() {
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      if (s[i][j] == 'B') {
        for (long long int k = 0; k < 4; k++) {
          long long int x = i + mv1[k], y = j + mv2[k];
          if ((x == n and y == m) or (s[x][y] == 'G')) {
            flag = false;
            return;
          } else if (s[x][y] == '.')
            s[x][y] = '#';
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    string ss(m + 2, '.');
    s[0] = s[n + 1] = ss;
    long long int cnt = 0, cnt1 = 0;
    for (long long int i = 1; i <= n; i++) {
      cin >> ss;
      for (long long int j = 0; j < ss.size(); j++) {
        if (ss[j] == 'G') cnt++;
        if (ss[j] == '#') cnt1++;
      }
      ss = '.' + ss + '.';
      s[i] = ss;
    }
    flag = true;
    if (n * m != 1 and cnt1 == n * m - 1) {
      cout << "No" << endl;
      continue;
    }
    if (cnt == 0) {
      cout << "Yes" << endl;
      continue;
    }
    func();
    if (!flag) {
      cout << "No" << endl;
      continue;
    } else {
      flag = true;
      bool flag2 = true;
      memset(visi, 0, sizeof visi);
      for (long long int i = 1; i <= n; i++) {
        for (long long int j = 1; j <= m; j++) {
          if (s[i][j] == 'G' and visi[i][j] == 0) {
            bool d = dfs(i, j);
            if (visi[i][j] == 0) {
              flag2 = false;
              break;
            }
            flag = true;
          }
        }
        if (!flag2) break;
      }
      if (flag2)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
  return 0;
}
