#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
bool chk(int x, int y) {
  if (x < 0 || x >= n) return false;
  if (y < 0 || y >= m) return false;
  return true;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int tests = 1;
  cin >> tests;
  for (int test = 1; test <= tests; ++test) {
    cin >> n >> m;
    string s[n];
    for (int i = 0; i < n; ++i) cin >> s[i];
    int g = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (s[i][j] == 'G') ++g;
        if (s[i][j] != 'B') continue;
        for (int x = -1; x <= 1; ++x) {
          for (int y = -1; y <= 1; ++y) {
            if (x == 0 && y == 0) continue;
            if (x != 0 && y != 0) continue;
            if (!chk(i + x, j + y)) continue;
            if (s[i + x][j + y] != 'B' && s[i + x][j + y] != 'G') {
              s[i + x][j + y] = '#';
            }
          }
        }
      }
    }
    if (g == 0) {
      cout << "Yes\n";
      continue;
    }
    bool pos = true;
    queue<pair<int, int> > q;
    q.push({n - 1, m - 1});
    vector<vector<bool> > r(n, vector<bool>(m, false));
    r[n - 1][m - 1] = true;
    while (!q.empty()) {
      pair<int, int> d = q.front();
      int i = d.first, j = d.second;
      q.pop();
      for (int x = -1; x <= 1; ++x) {
        for (int y = -1; y <= 1; ++y) {
          if (x == 0 && y == 0) continue;
          if (x != 0 && y != 0) continue;
          if (!chk(i + x, j + y)) continue;
          if (!r[i + x][j + y] && s[i + x][j + y] != '#') {
            r[i + x][j + y] = true;
            q.push({i + x, j + y});
          }
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (s[i][j] == 'G' && r[i][j] == false) pos = false;
        if (s[i][j] == 'B' && r[i][j] == true) pos = false;
      }
    }
    if (pos)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
