#include <bits/stdc++.h>
using namespace std;
void lc() { cout << endl; }
long long md(long long n) { return n % 1000000007; }
long long n, m;
char c[51][51];
long long a[51][51];
bool is(long long i, long long j) {
  return i >= 0 and i < n and j >= 0 and j < m;
}
void no() { cout << "No"; }
bool is1(long long i, long long j) {
  if (i < 0 or i >= n or j < 0 or j >= m) return false;
  if (a[i][j] == 0) return false;
  return true;
}
void dfs(long long i, long long j, long long &cnt) {
  a[i][j] = 0;
  if (is1(i + 1, j)) {
    if (c[i + 1][j] == 'G') cnt--;
    dfs(i + 1, j, cnt);
  }
  if (is1(i - 1, j)) {
    if (c[i - 1][j] == 'G') cnt--;
    dfs(i - 1, j, cnt);
  }
  if (is1(i, j - 1)) {
    if (c[i][j - 1] == 'G') cnt--;
    dfs(i, j - 1, cnt);
  }
  if (is1(i, j + 1)) {
    if (c[i][j + 1] == 'G') cnt--;
    dfs(i, j + 1, cnt);
  }
}
void solve() {
  long long cnt = 0;
  cin >> n >> m;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      a[i][j] = 1;
      char c1;
      cin >> c1;
      c[i][j] = c1;
      if (c1 == '#') a[i][j] = 0;
      if (c1 == 'G') cnt++;
    }
  if (cnt == 0) {
    cout << "Yes";
    return;
  }
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      if (c[i][j] == 'B') {
        if (is(i - 1, j)) {
          a[i - 1][j] = 0;
          if (c[i - 1][j] == 'G') {
            no();
            return;
          }
        }
        if (is(i + 1, j)) {
          a[i + 1][j] = 0;
          if (c[i + 1][j] == 'G') {
            no();
            return;
          }
        }
        if (is(i, j - 1)) {
          a[i][j - 1] = 0;
          if (c[i][j - 1] == 'G') {
            no();
            return;
          }
        }
        if (is(i, j + 1)) {
          a[i][j + 1] = 0;
          if (c[i][j + 1] == 'G') {
            no();
            return;
          }
        }
      }
    }
  if (a[n - 1][m - 1] == 0) {
    no();
    return;
  }
  dfs(n - 1, m - 1, cnt);
  if (cnt > 0)
    no();
  else
    cout << "Yes";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
    lc();
  }
}
