#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    vector<vector<char> > g(n + 2, vector<char>(m + 2, '#')),
        used(n + 2, vector<char>(m + 2));
    long long cntG = 0;
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= m; j++) {
        cin >> g[i][j];
        if (g[i][j] == 'G') cntG++;
      }
    }
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= m; j++) {
        if (g[i][j] == 'B') {
          if (g[i][j + 1] == '.') g[i][j + 1] = '#';
          if (g[i + 1][j] == '.') g[i + 1][j] = '#';
          if (g[i][j - 1] == '.') g[i][j - 1] = '#';
          if (g[i - 1][j] == '.') g[i - 1][j] = '#';
        }
      }
    }
    queue<pair<long long, long long> > q;
    if (g[n][m] != '#') q.push({n, m});
    used[n][m] = true;
    long long bad = 0, good = 0;
    while (!q.empty()) {
      long long i = q.front().first;
      long long j = q.front().second;
      q.pop();
      if (g[i][j] == 'G') good++;
      if (g[i][j] == 'B') bad++;
      for (long long t = 1; t <= 4; t++) {
        long long ni = i + (t == 1 ? 1 : (t == 2 ? -1 : 0));
        long long nj = j + (t == 3 ? 1 : (t == 4 ? -1 : 0));
        if (g[ni][nj] != '#' && !used[ni][nj]) {
          used[ni][nj] = true;
          q.push({ni, nj});
        }
      }
    }
    if (bad == 0 && good == cntG)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
