#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long N = 500 * 1000 + 13;
const long long p = 998244353;
void chalu_kr() {}
char grid[60][60];
long long n, m;
std::vector<long long> gud;
std::vector<long long> bad;
long long visit[60][60];
long long dist[60][60];
long long dx[] = {1, -1, 0, 0};
long long dy[] = {0, 0, 1, -1};
void dfs(long long r, long long c) {
  visit[r][c] = 1;
  for (long long i = 0; i < 4; i++) {
    long long x = r + dx[i];
    long long y = c + dy[i];
    if (x < 0 || x >= n || y < 0 || y >= m || visit[x][y] == 1) continue;
    if (grid[x][y] == '#' || grid[x][y] == 'B') continue;
    dfs(x, y);
  }
}
int32_t main() {
  chalu_kr();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  long double pi = 3.14159265358979323846264;
  while (t--) {
    gud.clear();
    bad.clear();
    cin >> n >> m;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        cin >> grid[i][j];
      }
    }
    if (n == 1 && m == 1) {
      cout << "Yes" << '\n';
      continue;
    }
    bool check = true;
    bool gud_pres = false;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (grid[i][j] == 'G') gud_pres = true;
        if (grid[i][j] == 'B') {
          for (long long k = 0; k < 4; k++) {
            long long x = i + dx[k];
            long long y = j + dy[k];
            if (x < 0 || x >= n || y < 0 || y >= m) continue;
            if (grid[x][y] == 'G') {
              check = false;
              break;
            } else {
              grid[x][y] = '#';
            }
          }
          if (!check) break;
        }
      }
      if (!check) break;
    }
    if (!check || (grid[n - 1][m - 1] == '#' && gud_pres)) {
      cout << "No" << '\n';
      continue;
    }
    memset(visit, 0, sizeof(visit));
    memset(dist, -1, sizeof(dist));
    dfs(n - 1, m - 1);
    check = true;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (grid[i][j] == 'G' && visit[i][j] == 0) {
          check = false;
          break;
        }
      }
      if (!check) break;
    }
    if (!check) {
      cout << "No" << '\n';
      continue;
    }
    cout << "Yes" << '\n';
  }
  return 0;
}
