#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long up = 1e5 + 10;
const long long MAXN = 1e6 + 10;
long long dx[4] = {1, -1, 0, 0};
long long dy[4] = {0, 0, 1, -1};
char a[100][100];
long long vis[100][100], n, m;
long long chk(long long x, long long y) {
  if (x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] == '.')
    return 1;
  else
    return 0;
}
void solve() {
  long long x, y, e, f;
  cin >> n >> m;
  long long fg = 0, g = 0;
  string s;
  queue<pair<long long, long long> > q;
  for (long long i = 1; i <= n; ++i) {
    cin >> s;
    for (long long j = 1; j <= m; ++j) {
      vis[i][j] = 0;
      a[i][j] = s[j - 1];
    }
  }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) {
      if (a[i][j] == 'G') {
        q.push({i, j});
        vis[i][j] = 1;
        fg = 1;
        g++;
      }
      if (a[i][j] == 'B') {
        if (i - 1 >= 0 && a[i - 1][j] == '.') {
          a[i - 1][j] = '#';
        }
        if (j - 1 >= 0 && a[i][j - 1] == '.') {
          a[i][j - 1] = '#';
        }
        if (i + 1 <= n && a[i + 1][j] == '.') {
          a[i + 1][j] = '#';
        }
        if (j + 1 <= m && a[i][j + 1] == '.') {
          a[i][j + 1] = '#';
        }
      }
    }
  }
  if (a[n][m] == 'B') {
    cout << "No" << '\n';
    return;
  }
  if (fg == 0) {
    cout << "Yes" << '\n';
    return;
  }
  long long cnt = 0;
  while (!q.empty()) {
    auto it = q.front();
    x = it.first;
    y = it.second;
    q.pop();
    if (x == n && y == m) {
      cnt++;
    }
    for (long long i = 0; i <= 3; ++i) {
      e = x + dx[i];
      f = y + dy[i];
      if (chk(e, f)) {
        if (!vis[e][f]) q.push({e, f});
        if (e == n && f == m) continue;
        vis[e][f] = 1;
      }
    }
  }
  if (g == cnt) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
