#include <bits/stdc++.h>
using namespace std;
char a[51][51];
long long vis[51][51];
long long n, m;
bool check(long long i, long long j) {
  if (i < 0 || j < 0 || i >= n || j >= m) return 1;
  if (a[i][j] == 'G')
    return 0;
  else if (a[i][j] == 'B')
    return 1;
  a[i][j] = '#';
  return 1;
}
void dfs(long long i, long long j) {
  if (i < 0 || j < 0 || i >= n || j >= m) return;
  if (vis[i][j] || a[i][j] == '#') return;
  vis[i][j] = 1;
  dfs(i + 1, j);
  dfs(i - 1, j);
  dfs(i, j - 1);
  dfs(i, j + 1);
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      vis[i][j] = 0;
      cin >> a[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (a[i][j] == 'B') {
        if ((!check(i - 1, j)) || (!check(i + 1, j)) || (!check(i, j + 1)) ||
            (!check(i, j - 1))) {
          cout << "No\n";
          return;
        }
      }
    }
  }
  dfs(n - 1, m - 1);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (a[i][j] == 'G' && !vis[i][j]) {
        cout << "No\n";
        return;
      }
    }
  }
  cout << "Yes\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
