#include <bits/stdc++.h>
using namespace std;
const int N = 55;
char gr[N][N];
bool vis[N][N];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
int n, m, t;
bool valid(int i, int j) {
  return i >= 0 && i < n && j >= 0 && j < m && (!vis[i][j]);
}
void DFS(int r, int c) {
  if (!valid(r, c) || gr[r][c] == '#') return;
  vis[r][c] = true;
  DFS(r - 1, c);
  DFS(r, c - 1);
  DFS(r, c + 1);
  DFS(r + 1, c);
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> gr[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (gr[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int r = i + dx[k];
            int c = j + dy[k];
            if (valid(r, c)) {
              if (gr[r][c] != 'G' && gr[r][c] != 'B') gr[r][c] = '#';
            }
          }
        }
      }
    }
    bool ok = true;
    DFS(n - 1, m - 1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (gr[i][j] == 'B' && vis[i][j] == 1) ok = false;
        if (gr[i][j] == 'G' && (!vis[i][j])) ok = false;
      }
    }
    if (ok == true)
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
    memset(vis, 0, sizeof(vis));
  }
  return 0;
}
