#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> adj[100005];
bool vis[100][100];
char x[100][100];
bool can(int i, int j) {
  return (i >= 0 && i < n && j >= 0 && j < m && x[i][j] != '#' && !vis[i][j]);
}
bool can2(int i, int j) { return (i >= 0 && i < n && j >= 0 && j < m); }
void DFS(int i, int j) {
  vis[i][j] = true;
  if (can(i + 1, j)) {
    DFS(i + 1, j);
  }
  if (can(i - 1, j)) {
    DFS(i - 1, j);
  }
  if (can(i, j + 1)) {
    DFS(i, j + 1);
  }
  if (can(i, j - 1)) {
    DFS(i, j - 1);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie();
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int gd = 0, bd = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++)
        cin >> x[i][j], gd += (x[i][j] == 'G'), bd += (x[i][j] == 'B');
    }
    if (!gd) {
      cout << "Yes\n";
      continue;
    }
    int ok = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (x[i][j] == 'B') {
          if (can2(i + 1, j) && x[i + 1][j] == '.') x[i + 1][j] = '#';
          if (can2(i - 1, j) && x[i - 1][j] == '.') x[i - 1][j] = '#';
          if (can2(i, j + 1) && x[i][j + 1] == '.') x[i][j + 1] = '#';
          if (can2(i, j - 1) && x[i][j - 1] == '.') x[i][j - 1] = '#';
        }
      }
    }
    if (x[n - 1][m - 1] == '#' || x[n - 1][m - 1] == 'B') {
      cout << "No\n";
      continue;
    }
    DFS(n - 1, m - 1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (x[i][j] == 'G' && !vis[i][j]) {
          ok = 1;
          break;
        }
        if (x[i][j] == 'B' && vis[i][j]) {
          ok = 2;
          break;
        }
      }
      if (!ok) break;
    }
    (!ok) ? cout << "Yes\n" : cout << "No\n";
    memset(vis, 0, sizeof vis);
  }
  return 0;
}
