#include <bits/stdc++.h>
using namespace std;
long long int n, t, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n >> m;
    char a[n][m];
    long long int vis[n][m];
    long long int f = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        vis[i][j] = 0;
        if (a[i][j] == 'G') sum++;
      }
    }
    if (sum == 0) {
      cout << "Yes" << endl;
      continue;
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          if (i > 0 && a[i - 1][j] == '.') a[i - 1][j] = '#';
          if (i < n - 1 && a[i + 1][j] == '.') a[i + 1][j] = '#';
          if (j > 0 && a[i][j - 1] == '.') a[i][j - 1] = '#';
          if (j < m - 1 && a[i][j + 1] == '.') a[i][j + 1] = '#';
          if ((i < n - 1 && a[i + 1][j] == 'G') ||
              (i > 0 && a[i - 1][j] == 'G') || (j > 0 && a[i][j - 1] == 'G') ||
              (j < m - 1 && a[i][j + 1] == 'G'))
            f = 1;
        }
      }
    }
    if (f == 1) {
      cout << "No" << endl;
      continue;
    }
    queue<pair<long long int, long long int>> q;
    if (a[n - 1][m - 1] != '#') q.push({n - 1, m - 1});
    long long int cnt = 0;
    vis[n - 1][m - 1] = 1;
    while (!q.empty()) {
      pair<long long int, long long int> p = q.front();
      q.pop();
      if (a[p.first][p.second] == 'G') cnt++;
      long long int i = p.first, j = p.second;
      if (i > 0 && vis[i - 1][j] == 0 && a[i - 1][j] != '#')
        q.push({i - 1, j}), vis[i - 1][j] = 1;
      if (i < n - 1 && vis[i + 1][j] == 0 && a[i + 1][j] != '#')
        q.push({i + 1, j}), vis[i + 1][j] = 1;
      if (j > 0 && vis[i][j - 1] == 0 && a[i][j - 1] != '#')
        q.push({i, j - 1}), vis[i][j - 1] = 1;
      if (j < m - 1 && vis[i][j + 1] == 0 && a[i][j + 1] != '#')
        q.push({i, j + 1}), vis[i][j + 1] = 1;
    }
    if (cnt == sum)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
