#include <bits/stdc++.h>
using namespace std;
int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
char mat[50][50];
int n, m;
int vis[50][50];
bool dfs(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m) return 0;
  if (vis[x][y] == 1 || mat[x][y] == '#' || mat[x][y] == 'B') return 0;
  vis[x][y] = 1;
  if (x == n - 1 && y == m - 1) return 1;
  for (int i = 0; i < 4; i++) {
    if (dfs(x + di[i], y + dj[i])) return 1;
  }
  return 0;
}
bool check() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == 'G') {
        for (int a = 0; a < 50; a++)
          for (int b = 0; b < 50; b++) vis[a][b] = 0;
        if (dfs(i, j) == false) return 0;
      }
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  int zz;
  cin >> zz;
  for (int zzz = 1; zzz <= zz; zzz++) {
    cin >> n >> m;
    int b = 0, g = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        cin >> mat[i][j];
        if (mat[i][j] == 'G') ++g;
        if (mat[i][j] == 'B') ++b;
      }
    if (g == 0) {
      cout << "Yes" << endl;
      continue;
    }
    int flag = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mat[i][j] == 'B') {
          for (int x = 0; x < 4; x++) {
            int y = x;
            if (i + di[x] >= n || i + di[x] < 0 || j + dj[y] >= m ||
                j + dj[y] < 0)
              continue;
            if (mat[i + di[x]][j + dj[y]] == 'G' ||
                (i + di[x] == n - 1 && j + dj[y] == m - 1)) {
              flag = 1;
              break;
            } else if (mat[i + di[x]][j + dj[y]] != 'B') {
              mat[i + di[x]][j + dj[y]] = '#';
            }
            mat[i + di[x]][j + dj[y]] = '#';
          }
        }
      }
    }
    if (check() && flag == 0 && mat[n - 1][m - 1] != '#')
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
