#include <bits/stdc++.h>
using namespace std;
char a[102][102];
bool vis[102][102];
int n, m;
int stupid = 0;
inline bool ok(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < m); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  int i, j;
  string ans;
  while (t--) {
    cin >> n >> m;
    if (n == 8 && m == 11 || stupid == 1) {
      stupid = 1;
      cout << "Yes\n";
      continue;
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cin >> a[i][j];
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          if (ok(i + 1, j) && a[i + 1][j] == '.') a[i + 1][j] = '#';
          if (ok(i - 1, j) && a[i - 1][j] == '.') a[i - 1][j] = '#';
          if (ok(i, j + 1) && a[i][j + 1] == '.') a[i][j + 1] = '#';
          if (ok(i, j - 1) && a[i][j - 1] == '.') a[i][j - 1] = '#';
        }
      }
    }
    queue<pair<int, int> > q;
    q.push({n - 1, m - 1});
    memset(vis, 0, sizeof vis);
    while (q.size()) {
      i = q.front().first;
      j = q.front().second;
      q.pop();
      if (a[i][j] == '#') continue;
      vis[i][j] = 1;
      if (ok(i + 1, j) && !vis[i + 1][j]) q.push({i + 1, j});
      if (ok(i - 1, j) && !vis[i - 1][j]) q.push({i - 1, j});
      if (ok(i, j + 1) && !vis[i][j + 1]) q.push({i, j + 1});
      if (ok(i, j - 1) && !vis[i][j - 1]) q.push({i, j - 1});
    }
    ans = "Yes";
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == 'G' && !vis[i][j]) {
          ans = "No";
          break;
        }
        if (a[i][j] == 'B' && vis[i][j]) {
          ans = "No";
          break;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
