#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr[55][55];
int vis[55][55];
void dfs(int x, int y) {
  if (x < 1 || y < 1 || x > n || y > m) return;
  if (!arr[x][y]) return;
  if (vis[x][y]) return;
  vis[x][y] = 1;
  arr[x][y] = 2;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
void block(int x, int y) {
  if (x < 1 || y < 1 || x > n || y > m) return;
  arr[x][y] = 0;
}
void loop() {
  cin >> n >> m;
  int g = 0;
  vector<pair<int, int> > G, B;
  for (int i = 1; i <= n; ++i) {
    string str;
    cin >> str;
    for (int j = 1; j <= m; ++j) {
      if (str[j - 1] == '#')
        arr[i][j] = 0;
      else if (str[j - 1] == '.')
        arr[i][j] = 1;
      else if (str[j - 1] == 'G') {
        arr[i][j] = 1;
        G.push_back(make_pair(i, j));
        ++g;
      } else if (str[j - 1] == 'B') {
        arr[i][j] = 1;
        B.push_back(make_pair(i, j));
      }
    }
  }
  for (auto pr : B) {
    int x = pr.first;
    int y = pr.second;
    block(x, y);
    block(x + 1, y);
    block(x - 1, y);
    block(x, y + 1);
    block(x, y - 1);
  }
  if (arr[n][m] == 0) {
    if (g == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
    return;
  } else {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j) vis[i][j] = 0;
    dfs(n, m);
    for (auto pr : G) {
      int x = pr.first;
      int y = pr.second;
      if (arr[x][y] != 2) {
        cout << "No\n";
        return;
      }
    }
  }
  cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int myTest;
  cin >> myTest;
  while (myTest--) {
    loop();
  }
}
