#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > neighbors(int i, int j, int n, int m) {
  vector<pair<int, int> > neighbors(0);
  if (i > 0) {
    neighbors.push_back(pair<int, int>(i - 1, j));
  }
  if (i < n - 1) {
    neighbors.push_back(pair<int, int>(i + 1, j));
  }
  if (j > 0) {
    neighbors.push_back(pair<int, int>(i, j - 1));
  }
  if (j < n - 1) {
    neighbors.push_back(pair<int, int>(i, j + 1));
  }
  return neighbors;
}
void wallBad(vector<vector<char> > &A, int i, int j) {
  int n = A.size();
  int m = A[0].size();
  vector<pair<int, int> > tack(0, make_pair(0, 0));
  tack = neighbors(i, j, n, m);
  set<pair<int, int> > visited = set<pair<int, int> >();
  while (tack.size() > 0) {
    pair<int, int> el = tack[0];
    int I = el.first;
    int J = el.second;
    tack.erase(tack.begin());
    if (visited.count(el) == 1) {
      continue;
    }
    visited.insert(el);
    if (A[I][J] == '.' || A[I][J] == '#') {
      A[I][J] = '#';
    } else {
      vector<pair<int, int> > ne = neighbors(I, J, n, m);
      tack.insert(tack.begin(), ne.begin(), ne.end());
    }
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<char> > A = vector<vector<char> >();
  for (int i = 0; i < n; i++) {
    vector<char> row = vector<char>(m, ' ');
    string row_s;
    cin >> row_s;
    for (int j = 0; j < m; j++) {
      row[j] = row_s[j];
    }
    A.push_back(row);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (A[i][j] == 'B') {
        wallBad(A, i, j);
      }
    }
  }
  vector<pair<int, int> > tack(0, make_pair(0, 0));
  if (A[n - 1][m - 1] == '.') {
    tack.push_back(pair<int, int>(n - 1, m - 1));
  }
  set<pair<int, int> > visited = set<pair<int, int> >();
  while (tack.size() > 0) {
    pair<int, int> el = tack[0];
    int i = tack[0].first;
    int j = tack[0].second;
    tack.erase(tack.begin());
    if (visited.count(el) == 1) {
      continue;
    }
    visited.insert(el);
    if (A[i][j] == '#') {
      continue;
    } else if (A[i][j] == 'G') {
      A[i][j] = 'g';
    }
    vector<pair<int, int> > ne = neighbors(i, j, n, m);
    tack.insert(tack.begin(), ne.begin(), ne.end());
  }
  string ans = "Yes\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (A[i][j] == 'G') {
        ans = "No\n";
      }
    }
  }
  cout << ans;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
