#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int t = 1;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<vector<char> > v(n, vector<char>(m));
    int s = n * m;
    vector<vector<int> > g(s);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> v[i][j];
      }
    }
    set<int> gd;
    set<int> bd;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (v[i][j] == 'G') {
          gd.insert((i * m + j));
        } else if (v[i][j] == 'B') {
          bd.insert(i * m + j);
        }
        if (i - 1 >= 0 && v[i - 1][j] != '#' && v[i][j] != '#') {
          g[i * m + j].push_back((i - 1) * m + j);
        }
        if (i + 1 < n && v[i + 1][j] != '#' && v[i][j] != '#') {
          g[i * m + j].push_back((i + 1) * m + j);
        }
        if (j - 1 >= 0 && v[i][j - 1] != '#' && v[i][j] != '#') {
          g[i * m + j].push_back(i * m + j - 1);
        }
        if (j + 1 < m && v[i][j] != '#' && v[i][j] != '#') {
          g[i * m + j].push_back(i * m + j + 1);
        }
      }
    }
    queue<int> q;
    q.push(m * n - 1);
    vector<bool> used(s);
    set<int> nn;
    while (!q.empty()) {
      int a = q.front();
      used[a] = 1;
      q.pop();
      for (int i = 0; i < g[a].size(); i++) {
        int to = g[a][i];
        if (bd.find(to) != bd.end()) {
          swap(to, g[a][g[a].size() - 1]);
          g[a].pop_back();
          nn.insert(a);
          i--;
        }
        if (used[to]) {
          used[to] = 1;
          q.push(to);
        }
      }
    }
    for (int i = 0; i < s; i++) {
      used[i] = 0;
    }
    q.push(n * m - 1);
    if (nn.find(n * m - 1) != nn.end() && gd.size()) {
      cout << "No" << endl;
      continue;
    }
    while (!q.empty()) {
      int a = q.front();
      q.pop();
      used[a] = 1;
      for (int i = 0; i < g[a].size(); i++) {
        int to = g[a][i];
        if (nn.find(to) == nn.end()) {
          if (gd.find(to) != gd.end()) {
            gd.erase(gd.find(to));
          }
          if (!used[to]) {
            used[to] = 1;
            q.push(to);
          }
        }
      }
    }
    if (gd.size()) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}
