#include <bits/stdc++.h>
using namespace std;
int vis[100][100];
char a[100][100];
int n, m, g2, b2;
void dfs(int r, int c) {
  vis[r][c] = 1;
  if (a[r][c] == 'G')
    g2++;
  else if (a[r][c] == 'B')
    b2++;
  if (vis[r + 1][c] == 0 && r + 1 < n && a[r + 1][c] != '#') dfs(r + 1, c);
  if (vis[r - 1][c] == 0 && r - 1 >= 0 && a[r - 1][c] != '#') dfs(r - 1, c);
  if (vis[r][c + 1] == 0 && c + 1 < m && a[r][c + 1] != '#') dfs(r, c + 1);
  if (vis[r][c - 1] == 0 && c - 1 >= 0 && a[r][c - 1] != '#') dfs(r, c - 1);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) cin >> a[i][j];
    int g1 = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          if (i + 1 < n && a[i + 1][j] == '.') a[i + 1][j] = '#';
          if (i - 1 >= 0 && a[i - 1][j] == '.') a[i - 1][j] = '#';
          if (j + 1 < m && a[i][j + 1] == '.') a[i][j + 1] = '#';
          if (j - 1 >= 0 && a[i][j - 1] == '.') a[i][j - 1] = '#';
        } else if (a[i][j] == 'G')
          g1++;
      }
    }
    g2 = 0;
    b2 = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) vis[i][j] = 0;
    if (a[n - 1][m - 1] != '#') dfs(n - 1, m - 1);
    if (g1 == g2 && b2 == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
