#include <bits/stdc++.h>
using namespace std;
string board[55];
int n, m;
bool valid(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < (int)(n); ++i) {
      cin >> board[i];
    }
    bool impossible = false;
    for (int i = 0; i < (int)(n); ++i)
      for (int j = 0; j < (int)(m); ++j)
        if (board[i][j] == 'B') {
          for (int di = -1; di <= (int)(1); ++di)
            for (int dj = -1; dj <= (int)(1); ++dj) {
              int ni = i + di;
              int nj = j + dj;
              if (!valid(ni, nj)) continue;
              if (board[ni][nj] == 'G') {
                impossible = true;
              }
              if (board[ni][nj] == '.') {
                board[ni][nj] = '#';
              }
            }
        }
    if (impossible) {
      cout << "No\n";
      continue;
    }
    int goods = 0;
    int bads = 0;
    for (int i = 0; i < (int)(n); ++i)
      for (int j = 0; j < (int)(m); ++j) {
        if (board[i][j] == 'G') ++goods;
        if (board[i][j] == 'B') ++bads;
      }
    int reachableGoods = 0;
    int reachableBads = 0;
    if (board[n - 1][m - 1] == '#') {
      cout << ((reachableGoods == goods && !reachableBads) ? "Yes" : "No")
           << endl;
      continue;
    }
    vector<vector<char>> visited(n, vector<char>(m, false));
    queue<pair<int, int>> q;
    q.push(make_pair(n - 1, m - 1));
    visited[n - 1][m - 1] = true;
    while (!q.empty()) {
      auto c = q.front();
      q.pop();
      int i = c.first;
      int j = c.second;
      if (board[i][j] == 'G') ++reachableGoods;
      if (board[i][j] == 'B') ++reachableBads;
      for (int di = -1; di <= (int)(1); ++di)
        for (int dj = -1; dj <= (int)(1); ++dj) {
          int ni = i + di;
          int nj = j + dj;
          if (valid(ni, nj) && board[ni][nj] != '#' && !visited[ni][nj]) {
            q.push(make_pair(ni, nj));
            visited[ni][nj] = true;
          }
        }
    }
    cout << ((reachableGoods == goods && !reachableBads) ? "Yes" : "No")
         << endl;
  }
  return 0;
}
