#include <bits/stdc++.h>
using namespace std;
int n, m;
bool valid(int a, int b) {
  if (a > 0 and a < n and b > 0 and b < m)
    return true;
  else
    return false;
}
void solve() {
  cin >> n >> m;
  int g = 0;
  char a[n][m];
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'G') g++;
    }
  }
  if (g == 0) {
    cout << "Yes" << endl;
    return;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] == 'B') {
        if (valid(i + 1, j) and a[i + 1][j] == '.') a[i + 1][j] = '#';
        if (valid(i - 1, j) and a[i - 1][j] == '.') a[i - 1][j] = '#';
        if (valid(i, j + 1) and a[i][j + 1] == '.') a[i][j + 1] = '#';
        if (valid(i, j - 1) and a[i][j - 1] == '.') a[i][j - 1] = '#';
      }
    }
  }
  if (a[n - 1][m - 1] == '#') {
    cout << "No" << endl;
    return;
  }
  queue<pair<int, int> > q;
  bool vis[n][m];
  memset(vis, false, sizeof(vis));
  vis[n - 1][m - 1];
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    q.pop();
    int i = cur.first;
    int j = cur.second;
    if (valid(i + 1, j) and !vis[i + 1][j] and a[i + 1][j] != '#') {
      q.push({i + 1, j});
      vis[i + 1][j] = true;
    }
    if (valid(i - 1, j) and !vis[i - 1][j] and a[i - 1][j] != '#') {
      q.push({i - 1, j});
      vis[i - 1][j] = true;
    }
    if (valid(i, j + 1) and !vis[i][j + 1] and a[i][j + 1] != '#') {
      q.push({i, j + 1});
      vis[i][j + 1] = true;
    }
    if (valid(i, j - 1) and !vis[i][j - 1] and a[i][j - 1] != '#') {
      q.push({i, j - 1});
      vis[i][j - 1] = true;
    }
  }
  bool ans = true;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if ((a[i][j] == 'G' and !vis[i][j]) or (a[i][j] == 'B' and vis[i][j])) {
        ans = false;
        break;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
