#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 1e5, inf = 3e18, mod = 1e9 + 7;
long long tc, n, m, q, a, b, c, d, i, j, k, cnt;
long long vst[60][60];
vector<long long> vec;
string second[60];
void dfs(long long r, long long c) {
  vst[r][c] = 1;
  if (second[r - 1][c] == 'B' || second[r + 1][c] == 'B' ||
      second[r][c - 1] == 'B' || second[r][c + 1] == 'B')
    return;
  if (second[r][c] == 'G') cnt--;
  if (second[r - 1][c] != '#' && !vst[r - 1][c]) dfs(r - 1, c);
  if (second[r + 1][c] != '#' && !vst[r + 1][c]) dfs(r + 1, c);
  if (second[r][c - 1] != '#' && !vst[r][c - 1]) dfs(r, c - 1);
  if (second[r][c + 1] != '#' && !vst[r][c + 1]) dfs(r, c + 1);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> tc;
  for (i = 0; i < 60; i++) second[0].push_back('#');
  while (tc--) {
    cnt = 0;
    cin >> n >> m;
    memset(vst, 0, sizeof vst);
    for (i = 1; i <= n; i++)
      cin >> second[i], second[i] = "#" + second[i] + "#";
    second[n + 1].clear();
    for (i = 0; i < 60; i++) second[n + 1].push_back('#');
    long long flag = 0;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++)
        if (second[i][j] == 'G') cnt++;
    dfs(n, m);
    if (cnt)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
}
