#include <bits/stdc++.h>
using namespace std;
void Suhaib_Sawalha() {
  int n, m;
  cin >> n >> m;
  vector<vector<char>> c(n, vector<char>(m));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> c[i][j];
  auto inside = [&](int i, int j) {
    return (i >= 0 && j >= 0 && i < n && j < m);
  };
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (c[i][j] == 'B') {
        for (int d = 0; d < 4; ++d) {
          int dx = i + (d == 0) - (d == 1);
          int dy = j + (d == 2) - (d == 3);
          if (inside(dx, dy)) {
            if (c[dx][dy] == 'G') {
              cout << "No";
              return;
            }
            if (c[dx][dy] == '.') c[dx][dy] = '#';
          }
        }
      }
    }
  }
  vector<vector<bool>> visited(n, vector<bool>(m));
  function<void(int, int)> dfs = [&](int i, int j) {
    if (!inside(i, j) || visited[i][j] || c[i][j] == '#') return;
    visited[i][j] = true;
    for (int d = 0; d < 4; ++d) {
      int dx = i + (d == 0) - (d == 1);
      int dy = j + (d == 2) - (d == 3);
      dfs(dx, dy);
    }
  };
  dfs(n - 1, m - 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (c[i][j] == 'G' && !visited[i][j]) {
        cout << "No";
        return;
      }
    }
  }
  cout << "Yes";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int _;
  for (cin >> _; _; --_, cout << '\n') Suhaib_Sawalha();
  return 0;
}
