#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
const int inf = 2e9 + 7;
const long long INF = INT64_MAX;
double eps = 1e-6;
const int mod = 20191208;
const int N = 1e2 + 10;
const double pi = acos(-1.0);
char s[N][N];
int X[4] = {-1, 1, 0, 0};
int Y[4] = {0, 0, -1, 1};
int n, m;
bool ok[N][N];
void dfs(int x, int y) {
  if (s[x][y] == '#') return;
  ok[x][y] = 1;
  for (int k = 0; k <= 3; k++) {
    int xx = x + X[k], yy = y + Y[k];
    if (xx >= 1 && xx <= n && yy >= 1 && yy <= m) {
      if (s[xx][yy] != '#' && !ok[xx][yy]) {
        dfs(xx, yy);
      }
    }
  }
}
int main() {
  int _;
  scanf("%d", &_);
  while (_--) {
    bool flag = 1;
    memset(ok, 0, sizeof(ok));
    scanf("%d", &n);
    scanf("%d", &m);
    for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (s[i][j] == 'B') {
          s[i][j] = '#';
          for (int k = 0; k <= 3; k++) {
            int x = i + X[k], y = j + Y[k];
            if (x >= 1 && x <= n && y >= 1 && y <= m) {
              if (s[x][y] == 'G') flag = 0;
              s[x][y] = '#';
            }
          }
        }
    dfs(n, m);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (s[i][j] == 'G' && !ok[i][j]) flag = 0;
    if (flag)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
