#include <bits/stdc++.h>
using namespace std;
long long int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
void zanj0() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long int dp[55][55];
void canReach(vector<string>& v, long long int i, long long int j) {
  if (i < 0 || j < 0 || i >= v.size() || j >= v[0].size() || v[i][j] == '#')
    return;
  if (dp[i][j] != -1) return;
  dp[i][j] = 1;
  for (long long int k = 0; k < 4; k++) {
    canReach(v, i + dir[k][0], j + dir[k][1]);
  }
  return;
}
void out(vector<string>& v) {
  for (auto& it : v) {
    cout << it << endl;
  }
  cout << endl;
}
void solve() {
  memset(dp, -1, sizeof dp);
  long long int n, m;
  cin >> n >> m;
  vector<string> v(n);
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<string> v2 = v;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (v[i][j] == 'B') {
        for (long long int k = 0; k < 4; k++) {
          long long int ni = i + dir[k][0];
          long long int nj = j + dir[k][1];
          if (ni < 0 || nj < 0 || ni >= v.size() || nj >= v[0].size() ||
              v[ni][nj] != '.') {
            continue;
          }
          v2[ni][nj] = '#';
        }
      }
    }
  }
  canReach(v2, n - 1, m - 1);
  bool ok = true;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (v[i][j] == 'B') {
        bool temp = false;
        for (long long int k = 0; k < 4; k++) {
          long long int ni = i + dir[k][0];
          long long int nj = j + dir[k][1];
          if (ni < 0 || nj < 0 || ni >= v.size() || nj >= v[0].size()) {
            continue;
          }
          temp = temp | dp[ni][nj] == 1;
        }
        ok = ok && !temp;
      }
      if (v[i][j] == 'G') {
        bool temp = false;
        for (long long int k = 0; k < 4; k++) {
          long long int ni = i + dir[k][0];
          long long int nj = j + dir[k][1];
          if (ni < 0 || nj < 0 || ni >= v.size() || nj >= v[0].size()) {
            continue;
          }
          temp = temp | dp[ni][nj] == 1;
        }
        ok = ok && temp;
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}
int main() {
  zanj0();
  long long int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
