#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {{1, 0}, {0, 1}, {0, -1}, {-1, 0}};
char mape[55][55];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  int T;
  cin >> T;
  queue<pair<int, int> > que;
  while (T--) {
    int n, m;
    cin >> n >> m;
    string ans = "No";
    memset(mape, '#', sizeof(mape));
    int goal = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        cin >> mape[i][j];
        if (mape[i][j] == 'G') {
          goal++;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (mape[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int ni = i + dir[k][0];
            int nj = j + dir[k][1];
            if (mape[ni][nj] == '.') {
              mape[ni][nj] = '#';
            }
          }
        }
      }
    }
    if (goal == 0) ans = "Yes";
    que.push({n, m});
    bool flag = false;
    mape[n][m] = '#';
    while (que.size()) {
      auto top = que.front();
      que.pop();
      for (int i = 0; i < 4; i++) {
        int ni = top.first + dir[i][0];
        int nj = top.second + dir[i][1];
        if (mape[ni][nj] != '#') {
          que.push({ni, nj});
          if (mape[ni][nj] == 'G') goal--;
          if (mape[ni][nj] == 'B') flag = true;
          mape[ni][nj] = '#';
        }
      }
    }
    if (!goal && !flag) {
      ans = "Yes";
    }
    cout << ans << endl;
  }
}
