#include <bits/stdc++.h>
using namespace std;
bool isGoogles = 0;
const long long maxn = 2e5 + 10;
const long long max_val = 2e5 + 10;
const long long mod = 1000000009;
const long long bits = 10;
long long caseNumber = 1;
int n, m;
bool vis[100][100];
char arr[100][100];
long long ans = 0;
bool flag = 0;
void dfs(int x, int y) {
  vis[x][y] = 1;
  if (arr[x][y] == 'G') ans++;
  if (arr[x][y] == '#') return;
  if (arr[x][y] == 'B') {
    return;
  }
  vector<int> fx = {1, -1, 0, 0};
  vector<int> fy = {0, 0, -1, 1};
  for (int i = 0; i < 4; i++) {
    long long xx = x + fx[i];
    long long yy = y + fy[i];
    if (xx < n && xx > -1 && yy < m && yy > -1 && !vis[xx][yy]) {
      dfs(xx, yy);
    }
  }
}
void jabru() {
  ans = 0;
  flag = 0;
  long long g = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) vis[i][j] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 'G') g++;
      if (arr[i][j] == 'B') {
        if (i + 1 < n && arr[i + 1][j] == '.') arr[i + 1][j] = '#';
        if (i - 1 > -1 && arr[i - 1][j] == '.') arr[i - 1][j] = '#';
        if (j + 1 < m && arr[i][j + 1] == '.') arr[i][j + 1] = '#';
        if (j - 1 > -1 && arr[i][j - 1] == '.') arr[i][j - 1] = '#';
      }
    }
  }
  if (g == 0) {
    cout << "Yes"
         << "\n";
    return;
  }
  if (arr[n - 1][m - 1] == '#') {
    cout << "No"
         << "\n";
    return;
  }
  arr[n - 1][m - 1] = 'G';
  dfs(n - 1, m - 1);
  g++;
  if (g == ans || g == 1) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }
}
bool TestCase = 1;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  t = 1;
  if (TestCase) {
    cin >> t;
  }
  while (t--) {
    if (isGoogles) {
      cout << "Case #" << caseNumber << ": ";
    }
    caseNumber++;
    jabru();
  }
  return 0;
}
