#include <bits/stdc++.h>
using namespace std;
char maz[55][55];
long long n, m, ng, nb, vis[55][55];
long long r[] = {0, 1, 0, -1};
long long c[] = {1, 0, -1, 0};
vector<long long> rb, cb, rg, cg;
bool dfsg(long long i, long long j) {
  if (i == m && j == n) return true;
  vis[i][j] = 1;
  bool ans = false;
  for (long long x = 0; x < 4; x++) {
    if ((i + r[x]) <= 0 || (i + r[x]) > n || (j + c[x]) <= 0 || (j + c[x]) > m)
      continue;
    if ((i + r[x]) == n && (j + c[x]) == m && maz[n][m] != '#') return true;
    if (vis[i + r[x]][j + c[x]] == 1 || maz[i + r[x]][j + c[x]] == '#')
      continue;
    ans |= dfsg(i + r[x], j + c[x]);
  }
  return ans;
}
bool dfs(long long i, long long j) {
  if (i == m && j == n) return false;
  vis[i][j] = 1;
  bool ans = true;
  for (long long x = 0; x < 4; x++) {
    if ((i + r[x]) <= 0 || (i + r[x]) > n || (j + c[x]) <= 0 || (j + c[x]) > m)
      continue;
    if ((i + r[x]) == n && (j + c[x]) == m) return false;
    if (vis[i + r[x]][j + c[x]] == 1 || maz[i + r[x]][j + c[x]] == '#' ||
        maz[i + r[x]][j + c[x]] == '.')
      continue;
    if (maz[i + r[x]][j + c[x]] == 'G') return false;
    ans &= dfs(i + r[x], j + c[x]);
  }
  return ans;
}
void solve() {
  rb.clear();
  rg.clear();
  cb.clear();
  cg.clear();
  ng = 0;
  nb = 0;
  cin >> n >> m;
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      cin >> maz[i][j];
      if (maz[i][j] == 'G') {
        ng++;
        rg.push_back(i);
        cg.push_back(j);
      }
      if (maz[i][j] == 'B') {
        nb++;
        rb.push_back(i);
        cb.push_back(j);
      }
    }
  }
  bool poss = true;
  if (ng == 0)
    cout << "Yes" << endl;
  else {
    for (long long i = 0; i < nb; i++) {
      memset(vis, 0, sizeof(vis));
      poss &= dfs(rb[i], cb[i]);
    }
    for (long long i = 0; i < ng; i++) {
      memset(vis, 0, sizeof(vis));
      poss &= dfsg(rg[i], cg[i]);
    }
    if (poss)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
void aux() {}
int main() {
  aux();
  long long _ = 1;
  cin >> _;
  while (_--) {
    solve();
  }
  return 0;
}
