#include <bits/stdc++.h>
using namespace std;
long long int vis[52][52];
char mat[52][52];
void block(long long int x, long long int y, long long int n, long long int m) {
  if (mat[x + 1][y] == '.' && x + 1 <= n) mat[x + 1][y] = '#';
  if (mat[x][y + 1] == '.' && y + 1 <= m) mat[x][y + 1] = '#';
  if (mat[x - 1][y] == '.' && x - 1 >= 1) mat[x - 1][y] = '#';
  if (mat[x][y - 1] == '.' && y - 1 >= 1) mat[x][y - 1] = '#';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m, i, j, k, l, x, y;
    cin >> n >> m;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) cin >> mat[i][j];
    }
    long long int g = 0;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (mat[i][j] == 'B') block(i, j, n, m);
        if (mat[i][j] == 'G') g++;
      }
    }
    queue<pair<long long int, long long int>> q;
    if (mat[n][m] == '.') q.push({n, m});
    long long int visg = 0;
    while (!q.empty()) {
      pair<long long int, long long int> pi = q.front();
      x = pi.first;
      y = pi.second;
      q.pop();
      vis[x][y] = 1;
      if (mat[x + 1][y] != '#' && x + 1 <= n && vis[x + 1][y] == 0) {
        q.push({x + 1, y});
        vis[x + 1][y] = 1;
      }
      if (mat[x][y + 1] != '#' && y + 1 <= m && vis[x][y + 1] == 0) {
        q.push({x, y + 1});
        vis[x][y + 1] = 1;
      }
      if (mat[x - 1][y] != '#' && x - 1 >= 1 && vis[x - 1][y] == 0) {
        q.push({x - 1, y});
        vis[x - 1][y];
      }
      if (mat[x][y - 1] != '#' && y - 1 >= 1 && vis[x][y - 1] == 0) {
        q.push({x, y - 1});
        vis[x][y - 1];
      }
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (mat[i][j] == 'G' && vis[i][j] == 1) visg++;
      }
    }
    if (visg == g) {
      cout << "Yes\n";
    } else
      cout << "No\n";
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) vis[i][j] = 0;
    }
  }
  return 0;
}
