#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<string> a(n + 2, string(m + 2, '#'));
    vector<pair<int, int> > gays, goods;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        cin >> a[i][j];
        if (a[i][j] == 'B')
          gays.push_back(make_pair(i, j));
        else if (a[i][j] == 'G')
          goods.push_back(make_pair(i, j));
      }
    }
    bool works = 1;
    for (auto fag : gays) {
      if (a[fag.first - 1][fag.second] == 'G' ||
          a[fag.first + 1][fag.second] == 'G' ||
          a[fag.first][fag.second - 1] == 'G' ||
          a[fag.first][fag.second + 1] == 'G')
        works = 0;
      if (a[fag.first - 1][fag.second] == '.')
        a[fag.first - 1][fag.second] = '#';
      if (a[fag.first + 1][fag.second] == '.')
        a[fag.first + 1][fag.second] = '#';
      if (a[fag.first][fag.second - 1] == '.')
        a[fag.first][fag.second - 1] = '#';
      if (a[fag.first][fag.second + 1] == '.')
        a[fag.first][fag.second + 1] = '#';
    }
    if (a[n][m] == '#' && !goods.empty())
      works = 0;
    else {
      queue<pair<int, int> > bfs;
      vector<vector<bool> > used(n + 2, vector<bool>(m + 2, 0));
      bfs.push(make_pair(n, m));
      used[n][m] = 1;
      while (!bfs.empty()) {
        auto u = bfs.front();
        bfs.pop();
        if (!used[u.first - 1][u.second] && a[u.first - 1][u.second] != '#') {
          used[u.first - 1][u.second] = 1;
          bfs.push(make_pair(u.first - 1, u.second));
        }
        if (!used[u.first + 1][u.second] && a[u.first + 1][u.second] != '#') {
          used[u.first + 1][u.second] = 1;
          bfs.push(make_pair(u.first + 1, u.second));
        }
        if (!used[u.first][u.second - 1] && a[u.first][u.second - 1] != '#') {
          used[u.first][u.second - 1] = 1;
          bfs.push(make_pair(u.first, u.second - 1));
        }
        if (!used[u.first][u.second + 1] && a[u.first][u.second + 1] != '#') {
          used[u.first][u.second + 1] = 1;
          bfs.push(make_pair(u.first, u.second + 1));
        }
      }
      for (auto bro : goods) {
        if (!used[bro.first][bro.second]) works = 0;
      }
    }
    if (works)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
