#include <bits/stdc++.h>
using namespace std;
long long n, m;
const long long MAXN = 100;
string a[MAXN];
long long drow[4] = {1, 0, -1, 0}, dcol[4] = {0, 1, 0, -1};
bool into(long long row, long long col) {
  return row >= 0 && row < n && col >= 0 && col < m;
}
bool ans = 1;
bool used[MAXN][MAXN];
void dfs(long long row, long long col) {
  used[row][col] = 1;
  for (long long i = 0; i < 4; i++) {
    long long rto = row + drow[i], cto = col + dcol[i];
    if (!into(rto, cto)) continue;
    if (a[rto][cto] != '#' && !used[rto][cto]) dfs(rto, cto);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (long long i = 0; i < n; i++) cin >> a[i];
    ans = 1;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          for (long long q = 0; q < 4; q++) {
            long long rto = i + drow[q], cto = j + dcol[q];
            if (!into(rto, cto)) continue;
            if (a[rto][cto] == 'G') ans = 0;
            if (a[rto][cto] == '.') a[rto][cto] = '#';
          }
        }
      }
    }
    if (ans == 0)
      cout << "No";
    else {
      for (long long i = 0; i < n; i++)
        for (long long j = 0; j < m; j++) used[i][j] = 0;
      if (a[n - 1][m - 1] != '#') dfs(n - 1, m - 1);
      for (long long i = 0; i < n; i++)
        for (long long j = 0; j < m; j++)
          if (a[i][j] == 'G')
            if (!used[i][j]) ans = 0;
      cout << ((ans) ? "Yes" : "No");
    }
    cout << '\n';
  }
  return 0;
}
