#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, m;
long long int r[4] = {0, 0, 1, -1};
long long int c[4] = {1, -1, 0, 0};
void solve() {
  cin >> n >> m;
  char a[n][m];
  vector<pair<long long, long long> > roots;
  long long int G = 0, B = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'G') {
        roots.push_back({i, j});
        G++;
      } else if (a[i][j] == 'B')
        B++;
    }
  }
  if (G == 0 || B == 0) {
    cout << "Yes";
    return;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] == 'B') {
        a[i][j] = '#';
        for (k = 0; k < 4; k++) {
          if (i + r[k] < n && i + r[k] >= 0 && j + c[k] >= 0 && j + c[k] < m) {
            if (a[i + r[k]][j + c[k]] == 'G') {
              cout << "No";
              return;
            } else
              a[i + r[k]][j + c[k]] = '#';
          }
        }
      }
    }
  }
  stack<pair<long long, long long> > s;
  map<pair<long long, long long>, long long int> vis;
  long long int flag = false;
  for (auto g : roots) {
    if (vis[g] == 0) {
      vis[g] = 1;
      flag = false;
      s.push(g);
      while (!s.empty()) {
        pair<long long, long long> p = s.top();
        s.pop();
        vis[p] = 1;
        if (p == make_pair(n - 1, m - 1)) {
          flag = true;
        }
        i = p.first;
        j = p.second;
        for (k = 0; k < 4; k++) {
          if (i + r[k] < n && i + r[k] >= 0 && j + c[k] >= 0 && j + c[k] < m) {
            if ((a[i + r[k]][j + c[k]] == '.' ||
                 a[i + r[k]][j + c[k]] == 'G') &&
                vis[{i + r[k], j + c[k]}] == 0) {
              vis[{i + r[k], j + c[k]}] = 1;
              s.push({i + r[k], j + c[k]});
            }
          }
        }
      }
      if (!flag) {
        cout << "No";
        return;
      }
    }
  }
  cout << "Yes";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int T = 1;
  cin >> T;
  long long h = T;
  while (T--) {
    solve();
    cout << endl;
  }
  return 0;
}
