#include <bits/stdc++.h>
using namespace std;
const int N = 51;
char grid[N][N];
int poss[N][N], vis[N][N];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int n, m;
bool canBloc(char c) { return c != 'G' && c != 'B'; }
int main() {
  int t;
  string s;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      cin >> s;
      for (int j = 1; j <= m; j++) grid[i][j] = s[j - 1];
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (grid[i][j] == 'B') {
          if (i + 1 <= n && canBloc(grid[i + 1][j])) grid[i + 1][j] = '#';
          if (i - 1 >= 1 && canBloc(grid[i - 1][j])) grid[i - 1][j] = '#';
          if (j + 1 <= m && canBloc(grid[i][j + 1])) grid[i][j + 1] = '#';
          if (j - 1 >= 1 && canBloc(grid[i][j - 1])) grid[i][j - 1] = '#';
        }
      }
    }
    memset(vis, 0, sizeof(vis));
    memset(poss, 0, sizeof(poss));
    poss[n][m] = (grid[n][m] != '#');
    int pos = 1;
    queue<pair<int, int> > Q;
    Q.push(make_pair(n, m));
    vis[n][m] = 1;
    while (!Q.empty()) {
      pair<int, int> pp = Q.front();
      Q.pop();
      int X, Y;
      for (int i = 0; i < 4; i++) {
        X = pp.first + dx[i];
        Y = pp.second + dy[i];
        if (X >= 1 && X <= n && Y >= 1 && Y <= m && grid[X][Y] != '#' &&
            !vis[X][Y]) {
          vis[X][Y] = 1;
          poss[X][Y] |= poss[pp.first][pp.second];
          Q.push(make_pair(X, Y));
        }
      }
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        if (grid[i][j] == 'G') pos &= poss[i][j];
      }
    if (pos)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
