#include <bits/stdc++.h>
using namespace std;
long long cl(long long a, long long b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
long long max_div[1000001];
vector<long long> prs;
void sieve() {
  for (long long i = 2; i <= 1000000; i++) {
    if (!max_div[i]) {
      for (long long j = i; j <= 1000000; j += i) {
        max_div[j] = i;
      }
    }
  }
  for (long long i = 2; i < 1000001; i++) {
    if (max_div[i] == i) prs.push_back(i);
  }
}
vector<long long> gp[100005];
bool vis[100005];
long long n, m;
bool dfs(long long a) {
  vis[a] = 1;
  if (a == m * n - 1) return 1;
  for (long long x : gp[a]) {
    if (x == m * n - 1) return 1;
    if (!vis[x]) {
      if (dfs(x)) return 1;
    }
  }
  return 0;
}
void solve() {
  cin >> n >> m;
  string s[n];
  for (long long i = 0; i < m * n; i++) gp[i].clear();
  for (long long i = 0; i < n; i++) cin >> s[i];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        if (i + 1 < n && s[i + 1][j] == '.') s[i + 1][j] = '#';
        if (j + 1 < m && s[i][j + 1] == '.') s[i][j + 1] = '#';
        if (i - 1 >= 0 && s[i - 1][j] == '.') s[i - 1][j] = '#';
        if (j - 1 >= 0 && s[i][j - 1] == '.') s[i][j - 1] = '#';
      }
    }
  }
  vector<long long> bb, gb;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (s[i][j] == 'B') bb.push_back(i * m + j);
      if (s[i][j] == 'G') gb.push_back(i * m + j);
      if (s[i][j] != '#') {
        if (i + 1 < n && s[i + 1][j] != '#') {
          gp[i * m + j].push_back((i + 1) * m + j);
          gp[(i + 1) * m + j].push_back(i * m + j);
        }
        if (j + 1 < m && s[i][j + 1] != '#') {
          gp[i * m + j].push_back(i * m + j + 1);
          gp[i * m + j + 1].push_back(i * m + j);
        }
      }
    }
  }
  memset(vis, 0, sizeof(vis));
  for (long long x : bb) {
    if (!vis[x] && dfs(x)) {
      cout << "No\n";
      return;
    }
  }
  memset(vis, 0, sizeof(vis));
  for (long long x : gb) {
    if (!vis[x] && !dfs(x)) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int32_t main() {
  sieve();
  long long t = 1;
  cin >> t;
  for (long long i = 0; i < t; i++) solve();
  return 0;
}
