#include <bits/stdc++.h>
using namespace std;
int n, m;
string s[53];
bool visited[53][53];
vector<string> mat;
bool DFS(int x, int y, int n, int m, vector<string> mat,
         vector<pair<int, int>> &v) {
  if (x == n - 1 && y == m - 1 && mat[n - 1][m - 1] != '#') return true;
  if (x >= n || y >= m) return false;
  if (x < 0 || y < 0) return false;
  if (visited[x][y] == true) return false;
  if (mat[x][y] == '#') return false;
  if (mat[x][y] == 'G') {
    pair<int, int> pie = make_pair(x, y);
    auto it = find(v.begin(), v.end(), pie);
    if (it != v.end()) v.erase(it);
  }
  visited[x][y] = true;
  if (DFS(x + 1, y, n, m, mat, v) == true) return true;
  if (DFS(x - 1, y, n, m, mat, v) == true) return true;
  if (DFS(x, y + 1, n, m, mat, v) == true) return true;
  if (DFS(x, y - 1, n, m, mat, v) == true) return true;
  return false;
}
int che(int i, int j) {
  if (i < 0 || i >= n || j < 0 || j >= m)
    return 1;
  else if (s[i][j] == 'G')
    return 0;
  else if (s[i][j] != 'B')
    s[i][j] = '#';
  return 1;
}
void solve() {
  cin >> n >> m;
  vector<pair<int, int>> v;
  mat.clear();
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'G') v.push_back({i, j});
      if (s[i][j] == 'B') {
        s[i][j] = '#';
        if (!che(i - 1, j)) {
          cout << "No\n";
          return;
        }
        if (!che(i, j - 1)) {
          cout << "No\n";
          return;
        }
        if (!che(i + 1, j)) {
          cout << "No\n";
          return;
        }
        if (!che(i, j + 1)) {
          cout << "No\n";
          return;
        }
      }
    }
    mat.push_back(s[i]);
  }
  while (!v.empty()) {
    pair<int, int> pai = v.back();
    v.pop_back();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) visited[i][j] = false;
    }
    if (!DFS(pai.first, pai.second, n, m, mat, v)) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
