#include <bits/stdc++.h>
using namespace std;
template <typename dataType>
dataType nthGrayCode(dataType n) {
  return (n ^ (n >> 1));
}
template <typename dataType>
void generateAllSubset(vector<dataType> &data) {
  int i, j, n;
  n = data.size();
  for (i = 0; i < (1 << n); i++) {
    for (j = 0; j < n; j++) {
      if (i & (1 << j)) {
        cout << data[j] << " ";
      }
    }
    cout << "\n";
  }
}
char mat[51][51];
bool reach(int i, int j, int n, int m, int visited[51][51]) {
  if (i == n - 1 && j == m - 1) {
    return true;
  }
  if (i > n || j > m || i < 0 || j < 0) {
    return false;
  }
  if (visited[i][j] == 1) return false;
  if (mat[i][j] == 'B' || mat[i][j] == '#') return false;
  visited[i][j] = 1;
  bool p1 = reach(i, j + 1, n, m, visited);
  bool p2 = reach(i, j - 1, n, m, visited);
  bool p3 = reach(i + 1, j, n, m, visited);
  bool p4 = reach(i - 1, j, n, m, visited);
  if (p1 || p2 || p3 || p4) return true;
  return false;
}
int main() {
  int t;
  scanf("%d", &t);
  ;
  while (t--) {
    int n, m;
    scanf("%d %d", &n, &m);
    ;
    int good = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> mat[i][j];
        if (mat[i][j] == 'G') good += 1;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mat[i][j] == 'B') {
          if (j + 1 < m && mat[i][j + 1] == '.') {
            mat[i][j + 1] = '#';
          }
          if (i + 1 < n && mat[i + 1][j] == '.') {
            mat[i + 1][j] = '#';
          }
          if (i - 1 >= 0 && mat[i - 1][j] == '.') {
            mat[i - 1][j] = '#';
          }
          if (j - 1 >= 0 && mat[i][j - 1] == '.') {
            mat[i][j - 1] = '#';
          }
        }
      }
    }
    if (mat[n - 1][m - 1] == 'B' || mat[n - 1][m - 1] == '#') {
      cout << "No" << endl;
      continue;
    }
    if (good == 0) {
      cout << "Yes" << endl;
      continue;
    }
    int flag = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mat[i][j] == 'G') {
          int visited[51][51];
          memset(visited, 0, sizeof(visited));
          if (!(reach(i, j, n, m, visited))) {
            flag = 1;
            break;
          }
        }
      }
    }
    if (flag == 1)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
    memset(mat, 0, sizeof(mat));
  }
}
