#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<pair<int, int>> moves = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int n, m;
bool valid(int i, int j) { return i >= 0 && j >= 0 && i < n && j < m; }
char s[100][100];
int uf[3000];
void uf_init() { memset(uf, -1, sizeof(uf)); }
int uf_find(int x) { return uf[x] < 0 ? x : uf[x] = uf_find(uf[x]); }
bool uf_join(int x, int y) {
  x = uf_find(x);
  y = uf_find(y);
  if (x == y) return false;
  if (uf[x] > uf[y]) swap(x, y);
  uf[x] += uf[y];
  uf[y] = x;
  return true;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) cin >> s[i][j];
    bool f = true;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        for (auto move : moves) {
          int ni = i + move.first, nj = j + move.second;
          if (valid(ni, nj)) {
            if (s[i][j] == 'G' && s[ni][nj] == 'B') f = false;
            if (s[i][j] == 'B' && s[ni][nj] == '.') s[ni][nj] = '#';
          }
        }
      }
    if (!f)
      cout << "No" << '\n';
    else {
      uf_init();
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
          for (auto move : moves) {
            int ni = i + move.first, nj = j + move.second;
            if (valid(ni, nj) && s[i][j] != '#' && s[ni][nj] != '#') {
              uf_join(i * m + j, ni * m + nj);
            }
          }
        }
      int last = (n - 1) * m + m - 1;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
          if (s[i][j] == 'G') {
            if (uf_find(i * m + j) != uf_find(last)) f = false;
          }
      if (!f)
        cout << "No" << '\n';
      else
        cout << "Yes" << '\n';
    }
  }
  return 0;
}
