#include <bits/stdc++.h>
using namespace std;
int n, m;
bool dfs(int i, int j, vector<vector<int>>& q, vector<vector<int>>& use) {
  if (q[i][j] == 2) q[i][j] = 1;
  if (i == n - 1 && j == m - 1) return true;
  bool f = false;
  if (i > 0) {
    if (use[i - 1][j] && q[i - 1][j]) {
      use[i - 1][j] = 0;
      f = dfs(i - 1, j, q, use);
    }
  }
  if (i < n - 1 && !f) {
    if (use[i + 1][j] && q[i + 1][j]) {
      use[i + 1][j] = 0;
      f = dfs(i + 1, j, q, use);
    }
  }
  if (j > 0 && !f) {
    if (use[i][j - 1] && q[i][j - 1]) {
      use[i][j - 1] = 0;
      f = dfs(i, j - 1, q, use);
    }
  }
  if (j < m - 1 && !f) {
    if (use[i][j + 1] && q[i][j + 1]) {
      use[i][j + 1] = 0;
      f = dfs(i, j + 1, q, use);
    }
  }
  return f;
}
void solve() {
  cin >> n >> m;
  vector<vector<int>> q(n, vector<int>(m, 1));
  bool e = true;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      if (c == '.' && q[i][j] != 0) q[i][j] = 1;
      if (c == '#') q[i][j] = 0;
      if (c == 'G')
        if (q[i][j] != 0)
          q[i][j] = 2;
        else {
          e = false;
        }
      if (c == 'B') {
        q[i][j] = 3;
        if (i > 0) {
          if (q[i - 1][j] == 2) {
            e = false;
          }
          q[i - 1][j] = 0;
        }
        if (i < n - 1) {
          if (q[i + 1][j] == 2) {
            e = false;
          }
          q[i + 1][j] = 0;
        }
        if (j > 0) {
          if (q[i][j - 1] == 2) {
            e = false;
          }
          q[i][j - 1] = 0;
        }
        if (j < m - 1) {
          if (q[i][j + 1] == 2) {
            e = false;
          }
          q[i][j + 1] = 0;
        }
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (q[i][j] == 2) {
        vector<vector<int>> use(n, vector<int>(m, 1));
        use[i][j] = 0;
        bool ok = dfs(i, j, q, use);
        if (!ok) {
          e = false;
        }
      }
    }
  if (e)
    cout << "yes" << '\n';
  else
    cout << "no" << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
