#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using iii = tuple<ll, ll, ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
using umap = unordered_map<ll, ll>;
void showArr(arr a) {
  for (auto i : a) cout << i << " ";
  cout << endl;
}
ll dx[] = {-1, 1, 0, 0};
ll dy[] = {0, 0, -1, 1};
ll flag = 0;
void dfs(ll i, ll j, vs a, bool vis[][51], ll n, ll m) {
  vis[i][j] = 1;
  if (i == n - 1 and j == m - 1) flag = 1;
  for (int k = 0; k < 4; k++) {
    ll x = i + dx[k];
    ll y = j + dy[k];
    if (x < n and y < m and x >= 0 and y >= 0 and vis[x][y] == 0 and
        a[x][y] != '#' and a[x][y] != 'B')
      dfs(x, y, a, vis, n, m);
  }
}
void dfs1(ll i, ll j, vs& a, bool vis[][51], ll n, ll m) {
  vis[i][j] = 1;
  if (a[i][j] == '.') {
    a[i][j] = '#';
    return;
  }
  for (int k = 0; k < 4; k++) {
    ll x = i + dx[k];
    ll y = j + dy[k];
    if (x < n and y < m and x >= 0 and y >= 0 and vis[x][y] == 0 and
        a[x][y] != '#' and a[x][y] != 'G')
      dfs1(x, y, a, vis, n, m);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(25);
  ll t;
  cin >> t;
  while (t--) {
    ll n, m;
    cin >> n >> m;
    vs a;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      a.push_back(s);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        bool vis[51][51] = {0};
        flag = 0;
        if (a[i][j] == 'B') {
          dfs1(i, j, a, vis, n, m);
        }
      }
    }
    ll ok = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        bool vis[51][51] = {0};
        flag = 0;
        if (a[i][j] == 'G') {
          dfs(i, j, a, vis, n, m);
          ok &= flag;
        }
      }
    }
    if (ok) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
