#include <bits/stdc++.h>
using namespace std;
string second[55];
int blk[55][55], vis[55][55], rh = 0;
int n, m;
void dfs(int i, int j) {
  vis[i][j] = 1;
  if (i == n - 1 and j == m - 1) {
    rh = 1;
    return;
  }
  int dx[] = {-1, 1, 0, 0};
  int dy[] = {0, 0, -1, 1};
  for (int k = 0; k < 4; k++) {
    int x = i + dx[k], y = j + dy[k];
    if (x < 0 or x >= n or y < 0 or y >= m or vis[x][y]) continue;
    if (!blk[x][y]) dfs(x, y);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    memset(blk, 0, sizeof(blk));
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> second[i];
    int gd = 0, bd = 0;
    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    int no = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (second[i][j] == '#') blk[i][j] = 1;
        if (second[i][j] == 'B')
          for (int k = 0; k < 4; k++) {
            blk[i][j] = 1;
            int x = i + dx[k], y = j + dy[k];
            if (x < 0 or x >= n or y < 0 or y >= m) continue;
            if (second[x][y] == 'G') no = 1;
            blk[x][y] = 1;
          }
      }
    }
    if (second[n - 1][m - 1] == 'B') no = 1;
    if (no) {
      cout << "No\n";
      continue;
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        rh = 0;
        if (second[i][j] == 'G') {
          memset(vis, 0, sizeof(vis));
          dfs(i, j);
          if (!rh) no = 1;
        }
      }
    }
    if (no)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
  return 0;
}
