#include <bits/stdc++.h>
using namespace std;
const int maxn = 55, dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
int dist[maxn][maxn];
vector<int> adj[maxn];
string s[maxn];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      fill(dist[i], dist[i] + m, 3e5);
    }
    bool f = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        for (int l = 0; l < 4; l++) {
          int x = i + dx[l], y = j + dy[l];
          if (~x && ~y && x < n && y < m && s[x][y] == 'B') {
            if (s[i][j] == 'G') f = 1;
            s[i][j] = 'C';
          }
        }
      }
    }
    queue<pair<int, int> > Q;
    if (s[n - 1][m - 1] != 'C') {
      Q.push(pair<int, int>(n - 1, m - 1));
      dist[n - 1][m - 1] = 0;
    }
    while (Q.size()) {
      auto P = Q.front();
      Q.pop();
      int x = P.first, y = P.second;
      for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (~nx && ~ny && nx < n && ny < m &&
            (s[nx][ny] == '.' || s[nx][ny] == 'G') && dist[nx][ny] == 3e5) {
          dist[nx][ny] = 0;
          Q.push(pair<int, int>(nx, ny));
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] == 'G' && dist[i][j]) {
          f = 1;
          break;
        }
      }
      if (f) break;
    }
    if (f)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
}
