#include <bits/stdc++.h>
using namespace std;
int x[] = {-1, 1, 0, 0};
int y[] = {0, 0, 1, -1};
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void dfs(vector<vector<char>> &v, int &B, int &G, int i, int j, int &m,
         int &n) {
  if (i < 0 || j < 0 || i >= m || j >= n || v[i][j] == '#') return;
  if (v[i][j] == 'G') G++;
  if (v[i][j] == 'B') B++;
  v[i][j] = '#';
  for (int k = 0; k < 4; k++) {
    int r = i + x[k], c = j + y[k];
    dfs(v, B, G, r, c, m, n);
  }
}
int main() {
  fast();
  int t;
  cin >> t;
  while (t--) {
    int m, n, g = 0, b = 0, B = 0, G = 0;
    cin >> m >> n;
    vector<vector<char>> v(m, vector<char>(n));
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        cin >> v[i][j];
        if (v[i][j] == 'G') g++;
        if (v[i][j] == 'B') b++;
      }
    }
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (v[i][j] == 'B') {
          if (i - 1 >= 0 && v[i - 1][j] == '.') v[i - 1][j] = '#';
          if (i + 1 < m && v[i + 1][j] == '.') v[i + 1][j] = '#';
          if (j - 1 >= 0 && v[i][j - 1] == '.') v[i][j - 1] = '#';
          if (j + 1 < n && v[i][j + 1] == '.') v[i][j + 1] = '#';
        }
      }
    }
    dfs(v, B, G, m - 1, n - 1, m, n);
    if (g == G && B == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
