#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int mod = 1e9 + 7;
const int M = 51;
int n, m;
string s[M];
bool vis[M][M];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char tmp[M];
bool valid(int x, int y) {
  if (x >= 0 && x < n && y >= 0 && y < m)
    return true;
  else
    return false;
}
bool side(int x, int y) {
  for (int k = 0; k < 4; k++) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if (valid(nx, ny)) {
      if (s[nx][ny] == 'G')
        return false;
      else if (s[nx][ny] != 'B')
        s[nx][ny] = '#';
    }
  }
  return true;
}
void dfs(int x, int y) {
  vis[x][y] = 1;
  for (int k = 0; k < 4; k++) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if (valid(nx, ny)) {
      if (!vis[nx][ny] && s[nx][ny] != '#') {
        dfs(nx, ny);
      }
    }
  }
}
void solve() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n - 1; i++) {
    scanf("%s", tmp);
    s[i] = tmp;
  }
  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= m - 1; j++) {
      if (s[i][j] == 'B') {
        if (!side(i, j)) {
          cout << "No" << endl;
          return;
        }
      }
    }
  }
  memset(vis, 0, sizeof(vis));
  ;
  if (s[n - 1][m - 1] != '#') dfs(n - 1, m - 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'G') {
        if (!vis[i][j]) {
          cout << "No" << endl;
          return;
        }
      }
    }
  }
  cout << "Yes" << endl;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
