#include <bits/stdc++.h>
using namespace std;
ifstream f("pixeli.in");
ofstream g("pixeli.out");
const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
const string da = "Yes\n", nu = "No\n";
unordered_map<char, int> ma{{'.', 0}, {'G', 2}, {'B', 3}, {'#', 1}};
vector<pair<int, int>> pozg, pozb;
vector<vector<int>> v;
int n, m;
string query();
void ocupa(pair<int, int>);
bool inside(pair<int, int>);
bool nuajunge(pair<int, int>);
int main() {
  int q;
  cin >> q;
  while (q--) {
    cin >> n >> m;
    pozb.clear();
    pozg.clear();
    v.clear();
    v.resize(n + 2, vector<int>(m + 2, 0));
    int rez = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        char ch;
        cin >> ch;
        v[i][j] = ma[ch];
        if (ch == 'B') {
          pozb.push_back({i, j});
          for (int t : {1, 3}) {
            int nx = i + dx[t];
            int ny = j + dy[t];
            if (inside(make_pair(nx, ny)))
              if (v[nx][ny] == 2) rez = 1;
          }
        }
        if (ch == 'G') {
          pozg.push_back({i, j});
          for (int t : {1, 3}) {
            int nx = i + dx[t];
            int ny = j + dy[t];
            if (inside(make_pair(nx, ny)))
              if (v[nx][ny] == 3) rez = 1;
          }
        }
      }
    if (rez)
      cout << nu;
    else
      cout << query();
  }
  return 0;
}
string query() {
  if (v[n][m] == 3) return nu;
  int pb = (int)pozb.size();
  int pg = (int)pozg.size();
  if (!pb) return da;
  for (auto i : pozb) ocupa(i);
  for (auto i : pozg)
    if (nuajunge(i)) return nu;
  return da;
}
void ocupa(pair<int, int> st) {
  vector<vector<int>> bif(n + 2, vector<int>(m + 2, 0));
  queue<pair<int, int>> q;
  q.push(st);
  bif[st.first][st.second] = 1;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    for (int t = 0; t < 4; t++) {
      int nx = p.first + dx[t];
      int ny = p.second + dy[t];
      if (inside(make_pair(nx, ny))) {
        if (v[nx][ny] <= 1)
          v[nx][ny] = 1;
        else if (!bif[nx][ny])
          bif[nx][ny] = 1, q.push({nx, ny});
      }
    }
  }
}
bool inside(pair<int, int> a) {
  return a.first > 0 && a.second > 0 && a.first <= n && a.second <= m;
}
bool nuajunge(pair<int, int> st) {
  queue<pair<int, int>> q;
  vector<vector<int>> bif(n + 2, vector<int>(m + 2, 0));
  bif[st.first][st.second] = 1;
  q.push(st);
  while (!q.empty()) {
    auto p = q.front();
    if (p == make_pair(n, m)) return 0;
    q.pop();
    for (int t = 0; t < 4; t++) {
      int nx = dx[t] + p.first;
      int ny = dy[t] + p.second;
      if (inside(make_pair(nx, ny))) {
        if (!bif[nx][ny] && v[nx][ny] != 1) {
          bif[nx][ny] = 1;
          q.push({nx, ny});
        }
      }
    }
  }
  return 1;
}
