#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
bool solve() {
  long long H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (long long i = 0; i < H; i++) cin >> S[i];
  bool g = 0, b = 0;
  for (long long i = 0; i < H; i++) {
    for (long long j = 0; j < W; j++) {
      if (S[i][j] == 'G') g = 1;
      if (S[i][j] == 'B') b = 1;
    }
  }
  if (!b || !g) return true;
  for (long long i = 0; i < H; i++) {
    for (long long j = 0; j < W; j++) {
      if (S[i][j] == 'B') {
        for (long long k = 0; k < 4; k++) {
          long long nx = i + dx[k], ny = j + dy[k];
          if (nx >= 0 && nx < H && ny >= 0 && ny < W) {
            if (S[nx][ny] == '.' && !(nx == H - 1 && ny == W - 1)) {
              S[nx][ny] = '#';
            }
          }
          if (nx == H - 1 && ny == W - 1) return false;
        }
      }
    }
  }
  for (long long i = 0; i < H; i++) {
    for (long long j = 0; j < W; j++) {
      if (S[i][j] != 'G') continue;
      bool F = 0;
      queue<pair<long long, long long> > Q;
      Q.push(pair<long long, long long>(i, j));
      bool vis[60][60] = {false};
      vis[i][j] = 1;
      while (!Q.empty()) {
        long long x = Q.front().first, y = Q.front().second;
        Q.pop();
        if (x == H - 1 && y == W - 1) {
          F = 1;
          break;
        }
        for (long long k = 0; k < 4; k++) {
          long long nx = x + dx[k], ny = y + dy[k];
          if (nx >= 0 && nx < H && ny >= 0 && ny < W) {
            if (vis[nx][ny] || S[nx][ny] == '#') continue;
            vis[nx][ny] = 1;
            Q.push(pair<long long, long long>(nx, ny));
          }
        }
      }
      if (!F) return false;
    }
  }
  return true;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    if (solve())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
