#include <bits/stdc++.h>
char gs[52][52];
bool gb[52][52], gp[52][52];
using namespace std;
void dfs(long long i, long long j) {
  gp[i][j] = 1, gb[i][j] = 1;
  if (!gb[i - 1][j]) dfs(i - 1, j);
  if (!gb[i][j - 1]) dfs(i, j - 1);
  if (!gb[i + 1][j]) dfs(i + 1, j);
  if (!gb[i][j + 1]) dfs(i, j + 1);
}
long long t, n, m, ky, nm, mm, sm;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  cin >> t;
  while (t--) {
    cin >> n >> m;
    memset(gb, 0, sizeof(gb));
    ky = 0, nm = n + 1, mm = m + 1, sm = max(nm, mm);
    for (long long i = 1; i < nm; i++)
      for (long long j = 1; j < mm; j++) {
        cin >> gs[i][j];
        gp[i][j] = 0;
        if (gs[i][j] == 'B')
          gb[i + 1][j] = gb[i - 1][j] = gb[i][j + 1] = gb[i][j - 1] = 1;
        else if (gs[i][j] == '#')
          gb[i][j] = 1;
      }
    for (long long i = 0; i < sm; i++)
      gb[i][0] = gb[0][i] = gb[sm][i] = gb[i][sm] = 1;
    if (!gb[n][m]) dfs(n, m);
    for (long long i = 1; i < nm; i++) {
      for (long long j = 1; j < mm; j++) {
        if (gs[i][j] == 'G') {
          if (!gp[i][j]) {
            ky = 1;
            break;
          }
        } else if (gs[i][j] == '#') {
          if (gp[i][j]) {
            ky = 1;
            break;
          }
        }
      }
    }
    if (ky)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
}
