#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, const U &b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, const U &b) {
  if (a < b) a = b;
}
int power(int a, int b, int mod, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % mod)
    if (b & 1) ans = 1LL * ans * a % mod;
  return ans;
}
char a[111][111];
int vst[111][111];
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int n, m;
bool ok(int u, int v) {
  if (u < 1 or v < 1 or u > n or v > m) return 1;
  return 0;
}
queue<pair<int, int> > q;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) vst[i][j] = 0;
    for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
    int fl = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (a[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int u = i + dx[k];
            int v = j + dy[k];
            if (ok(u, v)) continue;
            if (a[u][v] == 'G') {
              fl = 1;
              break;
            }
            if (a[u][v] == '.') a[u][v] = '#';
          }
        }
      }
      if (fl) break;
    }
    if (fl) {
      puts("No");
      continue;
    }
    int nn = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (a[i][j] == 'G') nn++;
    if (!nn) {
      puts("Yes");
      continue;
    }
    if (a[n][m] == '#') {
      puts("No");
      continue;
    }
    q.push({n, m});
    int ee = 0;
    while (!q.empty()) {
      pair<int, int> p = q.front();
      q.pop();
      vst[p.first][p.second] = 1;
      if (a[p.first][p.second] == 'G') ee++;
      for (int i = 0; i < 4; i++) {
        int u = p.first + dx[i];
        int v = p.second + dy[i];
        if (ok(u, v)) continue;
        if (a[u][v] == '#') continue;
        if (vst[u][v]) continue;
        q.push({u, v});
      }
    }
    if (ee == nn)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
