#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > d{{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
vector<vector<int> > g;
vector<pair<int, int> > good;
int n, m;
bool valid() {
  if (good.size() == 0) return true;
  if (g[n - 1][m - 1] == 0) return false;
  vector<pair<int, int> > q;
  q.push_back(make_pair(n - 1, m - 1));
  vector<vector<int> > vis(n, vector<int>(m, 0));
  vis[n - 1][m - 1] = 1;
  while (q.size() > 0) {
    pair<int, int> cur = q.back();
    q.pop_back();
    for (auto dxy : d) {
      int nx = dxy[0] + cur.first, ny = dxy[1] + cur.second;
      if (nx >= n || nx < 0) continue;
      if (ny >= m || ny < 0) continue;
      if (vis[nx][ny] || g[nx][ny] == 0) continue;
      q.push_back(make_pair(nx, ny));
      vis[nx][ny] = 1;
    }
  }
  for (auto a : good) {
    if (!vis[a.first][a.second]) return false;
  }
  return true;
}
string solve() {
  cin >> n >> m;
  g.resize(n);
  for (auto i = (0); i < (n); i++) g[i] = vector<int>(m, 1);
  good.clear();
  for (auto i = (0); i < (n); i++) {
    string t;
    cin >> t;
    for (auto j = (0); j < (m); j++) {
      switch (t[j]) {
        case '#':
          g[i][j] = 0;
          break;
        case 'G':
          good.push_back(make_pair(i, j));
          break;
        case 'B':
          g[i][j] = 0;
          for (auto dxy : d) {
            int nx = dxy[0] + i, ny = dxy[1] + j;
            if (nx >= n || nx < 0) continue;
            if (ny >= m || ny < 0) continue;
            g[nx][ny] = 0;
          }
          break;
      }
    }
  }
  if (valid()) return "Yes";
  return "No";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  for (auto i = (0); i < (t); i++) {
    cout << solve() << endl;
  }
}
