#include <bits/stdc++.h>
using namespace std;
long long int fastpow(long long int base, long long int exp, long long int M) {
  long long int res = 1;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % M;
    base = (base * base) % M;
    exp >>= 1;
  }
  return res;
}
long long int n, m;
vector<long long int> dx = {1, 0, -1, 0};
vector<long long int> dy = {0, 1, 0, -1};
vector<vector<long long int>> vis;
vector<vector<char>> a;
void dfs(long long int x, long long int y) {
  if (x >= n || y >= m || x < 0 || y < 0) {
    return;
  }
  if (vis[x][y]) return;
  if (a[x][y] == '#') return;
  vis[x][y] = 1;
  if (a[x][y] == '.') {
    if (x + 1 < n) {
      if (a[x + 1][y] == 'B') {
        return;
      }
    }
    if (y + 1 < m) {
      if (a[x][y + 1] == 'B') {
        return;
      }
    }
    if (x - 1 >= 0) {
      if (a[x - 1][y] == 'B') {
        return;
      }
    }
    if (y - 1 >= 0) {
      if (a[x][y - 1] == 'B') {
        return;
      }
    }
  }
  for (long long int i = 0; i <= 3; ++i) {
    dfs(x + dx[i], y + dy[i]);
  }
}
void solve() {
  vis.clear();
  a.clear();
  cin >> n >> m;
  vis.resize(n, vector<long long int>(m, 0));
  a.resize(n, vector<char>(m));
  for (long long int i = 0; i <= n - 1; ++i) {
    for (long long int j = 0; j <= m - 1; ++j) {
      cin >> a[i][j];
    }
  }
  dfs(n - 1, m - 1);
  for (long long int i = 0; i <= n - 1; ++i) {
    for (long long int j = 0; j <= m - 1; ++j) {
      if (a[i][j] == 'G' && (!vis[i][j])) {
        cout << "No\n";
        return;
      }
      if (a[i][j] == 'B' && vis[i][j]) {
        cout << "No\n";
        return;
      }
    }
  }
  cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
