#include <bits/stdc++.h>
using namespace std;
int isvalid(int i, int j, int n, int m) {
  if (i < n && i >= 0 && j < m && j >= 0) return 1;
  return 0;
}
void solve() {
  int n, m;
  cin >> n >> m;
  char s[n][m];
  int g = 0;
  for (int i = (int)0; i <= (int)n - 1; ++i) {
    for (int j = (int)0; j <= (int)m - 1; ++j) {
      cin >> s[i][j];
      if (s[i][j] == 'G') ++g;
    }
  }
  if (g == 0) {
    cout << "Yes\n";
    return;
  }
  for (int i = (int)0; i <= (int)n - 1; ++i) {
    for (int j = (int)0; j <= (int)m - 1; ++j) {
      if (s[i][j] == 'B') {
        if (isvalid(i, j + 1, n, m) && s[i][j + 1] == '.') s[i][j + 1] = '#';
        if (isvalid(i + 1, j, n, m) && s[i + 1][j] == '.') s[i + 1][j] = '#';
        if (isvalid(i, j - 1, n, m) && s[i][j - 1] == '.') s[i][j - 1] = '#';
        if (isvalid(i - 1, j, n, m) && s[i - 1][j] == '.') s[i - 1][j] = '#';
      }
    }
  }
  if (s[n - 1][m - 1] == '#') {
    cout << "No\n";
    return;
  }
  queue<pair<int, int> > que;
  int vis[n][m];
  for (int i = (int)0; i <= (int)n - 1; ++i)
    for (int j = (int)0; j <= (int)m - 1; ++j) vis[i][j] = 0;
  que.push({n - 1, m - 1});
  while (que.empty() != 1) {
    pair<int, int> p = que.front();
    que.pop();
    int i = p.first;
    int j = p.second;
    if (isvalid(i, j + 1, n, m) && s[i][j + 1] != '#' && vis[i][j + 1] == 0) {
      que.push({i, j + 1});
      vis[i][j + 1] = 1;
    }
    if (isvalid(i + 1, j, n, m) && s[i + 1][j] != '#' && vis[i + 1][j] == 0) {
      que.push({i + 1, j});
      vis[i + 1][j] = 1;
    }
    if (isvalid(i - 1, j, n, m) && s[i - 1][j] != '#' && vis[i - 1][j] == 0) {
      que.push({i - 1, j});
      vis[i - 1][j] = 1;
    }
    if (isvalid(i, j - 1, n, m) && s[i][j - 1] != '#' && vis[i][j - 1] == 0) {
      que.push({i, j - 1});
      vis[i][j - 1] = 1;
    }
  }
  int f = 1;
  for (int i = (int)0; i <= (int)n - 1; ++i) {
    for (int j = (int)0; j <= (int)m - 1; ++j) {
      if (s[i][j] == 'G') {
        if (vis[i][j] != 1) {
          f = 0;
          break;
        }
      }
      if (s[i][j] == 'B') {
        if (vis[i][j] == 1) {
          f = 0;
          break;
        }
      }
    }
    if (!f) break;
  }
  if (f)
    cout << "Yes\n";
  else
    cout << "No\n";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) solve();
}
