#include <bits/stdc++.h>
using namespace std;
const long long N = 51;
const long long md = 1e9 + 7;
vector<string> a(N);
long long R = 0, n, m, z = 0;
bool us[N][N];
void dfs(long long i, long long j) {
  queue<pair<long long, long long> > q;
  R = 0;
  z = 0;
  q.push({i, j});
  us[i][j] = true;
  while (int(q.size()) != 0) {
    pair<long long, long long> v = q.front();
    q.pop();
    if (a[v.first][v.second] == 'G') {
      R++;
    }
    if (a[v.first][v.second] == 'B') {
      z = 1;
    }
    if (a[v.first][v.second] != '#') {
      if (v.first > 0 && us[v.first - 1][v.second] == 0 &&
          a[v.first - 1][v.second] != '#') {
        q.push({v.first - 1, v.second});
        us[v.first - 1][v.second] = 1;
      }
      if (v.first < n - 1 && us[v.first + 1][v.second] == 0 &&
          a[v.first + 1][v.second] != '#') {
        q.push({v.first + 1, v.second});
        us[v.first + 1][v.second] = 1;
      }
      if (v.second > 0 && us[v.first][v.second - 1] == 0 &&
          a[v.first][v.second - 1] != '#') {
        q.push({v.first, v.second - 1});
        us[v.first][v.second - 1] = 1;
      }
      if (v.second < m - 1 && us[v.first][v.second + 1] == 0 &&
          a[v.first][v.second + 1] != '#') {
        q.push({v.first, v.second + 1});
        us[v.first][v.second + 1] = 1;
      }
    }
  }
}
int main() {
  long long i, j, w, r = 0, x, l, k, q;
  cin >> q;
  while (q--) {
    cin >> n >> m;
    r = 0;
    for (long long i = 0; i < (n); i++) cin >> a[i];
    for (long long i = 0; i < (n); i++)
      for (long long j = 0; j < (m); j++) us[i][j] = false;
    for (long long i = 0; i < (n); i++)
      for (long long j = 0; j < (m); j++) {
        if (a[i][j] == 'G') r++;
        if (a[i][j] == 'B') {
          if (i > 0 && a[i - 1][j] == '.') a[i - 1][j] = '#';
          if (i < n - 1 && a[i + 1][j] == '.') a[i + 1][j] = '#';
          if (j > 0 && a[i][j - 1] == '.') a[i][j - 1] = '#';
          if (j < m - 1 && a[i][j + 1] == '.') a[i][j + 1] = '#';
        }
      }
    dfs(n - 1, m - 1);
    if (R == r && z == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
