#include <bits/stdc++.h>
using namespace std;
int xdir[4] = {0, 1, 0, -1};
int ydir[4] = {1, 0, -1, 0};
void check(int x, int y, vector<string>& temp, int n, int m) {
  if (temp[x][y] != 'B') return;
  for (int i = 0; i < 4; i++) {
    if (x + xdir[i] >= 0 && y + ydir[i] >= 0 && x + xdir[i] < n &&
        y + ydir[i] < m && temp[x + xdir[i]][y + ydir[i]] == '.')
      temp[x + xdir[i]][y + ydir[i]] = '#';
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<string> a;
    for (int i = 0; i < n; i++) {
      string temp;
      cin >> temp;
      a.push_back(temp);
    }
    int good = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'G') good++;
        check(i, j, a, n, m);
      }
    }
    queue<pair<int, int> > Q;
    vector<vector<bool> > visited(n, vector<bool>(m, false));
    Q.push(make_pair(n - 1, m - 1));
    visited[n - 1][m - 1] = true;
    bool ans = true;
    if (a[n - 1][m - 1] != '#') {
      while (!Q.empty()) {
        pair<int, int> p = Q.front();
        int x = p.first;
        int y = p.second;
        Q.pop();
        for (int i = 0; i < 4; i++) {
          if (x + xdir[i] >= 0 && y + ydir[i] >= 0 && x + xdir[i] < n &&
              y + ydir[i] < m && a[x + xdir[i]][y + ydir[i]] != '#' &&
              !visited[x + xdir[i]][y + ydir[i]]) {
            visited[x + xdir[i]][y + ydir[i]] = true;
            Q.push(make_pair(x + xdir[i], y + ydir[i]));
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'G' && !visited[i][j]) ans = false;
        if (a[i][j] == 'B' && visited[i][j]) ans = false;
      }
    }
    if (ans)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
