#include <bits/stdc++.h>
using namespace std;
int n, m;
int good;
int dx[3] = {-1, 0, 1};
int chk(int x, int y, vector<vector<int>> &vis) {
  return x >= 0 and y >= 0 and x < n and y < m and !vis[x][y];
}
void dfs(int x, int y, vector<string> &a, vector<vector<int>> &vis) {
  vis[x][y] = 1;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (abs(dx[i]) + abs(dx[j]) != 1) continue;
      int nx = x + dx[i];
      int ny = y + dx[j];
      if (chk(nx, ny, vis) and a[nx][ny] != '#') dfs(nx, ny, a, vis);
    }
  }
  if (a[x][y] == 'G') good++;
}
void solve() {
  cin >> n >> m;
  vector<string> a(n);
  vector<vector<int>> vis(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) cin >> a[i];
  good = 0;
  int tot = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (a[i][j] == 'G') tot++;
  if (tot == 0) {
    if (a[n - 1][m - 1] != 'B')
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return;
  }
  if (a[n - 1][m - 1] == '#' || a[n - 1][m - 1] == 'B') {
    cout << "No" << endl;
    return;
  }
  dfs(n - 1, m - 1, a, vis);
  if (tot != good) {
    cout << "No" << endl;
    return;
  }
  int flag = (a[n - 1][m - 1] != 'B');
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) vis[i][j] = 0;
  a[n - 1][m - 1] = 'G';
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < m; y++) {
      if (a[x][y] == 'B') {
        for (int i = 0; i < 3; i++)
          for (int j = 0; j < 3; j++) {
            if (abs(dx[i]) + abs(dx[j]) != 1) continue;
            int nx = x + dx[i];
            int ny = y + dx[j];
            if (chk(nx, ny, vis) and a[nx][ny] == 'G') flag = 0;
          }
      }
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
