#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T maxs(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T mins(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
long long solve() {
  long long n, m;
  cin >> n >> m;
  vector<vector<char>> a(n + 1, vector<char>(m + 1));
  long long cnt = 0;
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'G') cnt++;
    }
  }
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      if (a[i][j] == 'B') {
        if (i - 1 > 0) {
          if (a[i - 1][j] == 'G') {
            cout << "No"
                 << "\n";
            return 0;
          }
          if (a[i - 1][j] == '.') a[i - 1][j] = '#';
        }
        if (i + 1 <= n) {
          if (a[i + 1][j] == 'G') {
            cout << "No"
                 << "\n";
            return 0;
          }
          if (a[i + 1][j] == '.') a[i + 1][j] = '#';
        }
        if (j - 1 > 0) {
          if (a[i][j - 1] == 'G') {
            cout << "No"
                 << "\n";
            return 0;
          }
          if (a[i][j - 1] == '.') a[i][j - 1] = '#';
        }
        if (j + 1 <= m) {
          if (a[i][j + 1] == 'G') {
            cout << "No"
                 << "\n";
            return 0;
          }
          if (a[i][j + 1] == '.') a[i][j + 1] = '#';
        }
      }
    }
  }
  vector<pair<long long, long long>> vec = {{n, m}};
  vector<vector<long long>> vis(n + 1, vector<long long>(m + 1));
  vector<pair<long long, long long>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  if (a[n][m] == '#') {
    if (cnt == 0) {
      cout << "Yes"
           << "\n";
    } else {
      cout << "No"
           << "\n";
    }
    return 0;
  }
  for (long long i = 0; i < (long long)vec.size(); i++) {
    long long first = vec[i].first, second = vec[i].second;
    if (a[first][second] == 'G') cnt--;
    if (a[first][second] == 'B') {
      cout << "No"
           << "\n";
      return 0;
    }
    vis[first][second] = 1;
    for (auto k : dir) {
      long long nx = first + k.first, ny = second + k.second;
      if (nx <= n && nx > 0 && ny <= m && ny > 0 && a[nx][ny] != '#' &&
          !vis[nx][ny]) {
        vis[nx][ny] = 1;
        vec.push_back({nx, ny});
      }
    }
  }
  if (cnt == 0)
    cout << "Yes"
         << "\n";
  else
    cout << "No"
         << "\n";
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
