#include <bits/stdc++.h>
using namespace std;
long long q, dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}, n, m;
bool used[55][55];
char a[55][55];
bool check(long long x, long long y) {
  return x >= 0 && y >= 0 && x < n && y < m;
}
void dfs(long long x, long long y, long long& cnt) {
  if (used[x][y]) return;
  used[x][y] = 1;
  if (a[x][y] == 'G') cnt++;
  if (a[x][y] == 'B') cnt = 1e9;
  for (long long i = 0; i < 4; ++i) {
    long long nx = x + dx[i], ny = y + dy[i];
    if (check(nx, ny) && a[nx][ny] != '#') dfs(nx, ny, cnt);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cout.precision(40);
  cin >> q;
  while (q--) {
    cin >> n >> m;
    long long good = 0;
    for (long long i = 0; i < n; ++i) {
      for (long long j = 0; j < m; ++j) {
        cin >> a[i][j];
        if (a[i][j] == 'G') good++;
        used[i][j] = 0;
      }
    }
    if (!good) {
      cout << "Yes\n";
      continue;
    }
    for (long long i = 0; i < n; ++i) {
      for (long long j = 0; j < m; ++j) {
        if (a[i][j] != 'B') continue;
        for (long long k = 0; k < 4; ++k) {
          long long nx = i + dx[k], ny = j + dy[k];
          if (check(nx, ny) && a[nx][ny] == '.') a[nx][ny] = '#';
        }
      }
    }
    if (a[n - 1][m - 1] == '#') {
      cout << "No\n";
      continue;
    }
    long long cgood = 0;
    dfs(n - 1, m - 1, cgood);
    if (cgood != good)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
}
