#include <bits/stdc++.h>
using namespace std;
const long long N = 100;
long long te, n, m, b, g, dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}, w[N][N],
                          cnt, res;
char c[N][N];
void dfs(long long x, long long y) {
  w[x][y] = 1;
  if (c[x][y] == 'G') cnt++;
  if (c[x][y] == 'B') res++;
  for (long long i = 0; i < 4; i++)
    if (x + dx[i] >= 1 && x + dx[i] <= n && y + dy[i] >= 1 && y + dy[i] <= m &&
        c[x + dx[i]][y + dy[i]] != '#' && !w[x + dx[i]][y + dy[i]])
      dfs(x + dx[i], y + dy[i]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> te;
  for (; te--;) {
    cin >> n >> m;
    cnt = b = g = 0;
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= m; j++)
        cin >> c[i][j], b += (c[i][j] == 'B'), g += (c[i][j] == 'G'),
            w[i][j] = 0;
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= m; j++)
        if (c[i][j] == 'B')
          for (long long k = 0; k < 4; k++)
            if (i + dx[k] >= 1 && i + dx[k] <= n && j + dy[k] >= 1 &&
                j + dy[k] <= m && c[i + dx[k]][j + dy[k]] == '.')
              c[i + dx[k]][j + dy[k]] = '#';
    if (c[n][m] != '#') dfs(n, m);
    if (cnt == g && res == 0)
      cout << "yes\n";
    else
      cout << "no\n";
  }
}
