#include <bits/stdc++.h>
using namespace std;
struct node {
  int val;
  int pos;
};
bool ac(int x, int y) { return x > y; }
int n, m;
bool good(int i, int j) { return (i >= 0 && i < n && j >= 0 && j < m); }
int dp[51][51];
int vis[51][51];
string s[51];
void find(int i, int j) {
  if (s[i][j] == '#') return;
  vis[i][j] = 1;
  if (good(i + 1, j) && !vis[i + 1][j]) {
    find(i + 1, j);
  }
  if (good(i - 1, j) && !vis[i - 1][j]) {
    find(i - 1, j);
  }
  if (good(i, j + 1) && !vis[i][j + 1]) {
    find(i, j + 1);
  }
  if (good(i, j - 1) && !vis[i][j - 1]) {
    find(i, j - 1);
  }
}
class DSolveTheMaze {
 public:
  void solve(std::istream& cin, std::ostream& cout) {
    int t;
    cin >> t;
    while (t--) {
      memset(dp, -1, sizeof(dp));
      memset(vis, 0, sizeof(vis));
      cin >> n >> m;
      for (int i = 0; i < n; i++) {
        cin >> s[i];
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (s[i][j] == 'B') {
            if (good(i + 1, j) && s[i + 1][j] == '.') {
              s[i + 1][j] = '#';
            }
            if (good(i - 1, j) && s[i - 1][j] == '.') {
              s[i - 1][j] = '#';
            }
            if (good(i, j + 1) && s[i][j + 1] == '.') {
              s[i][j + 1] = '#';
            }
            if (good(i, j - 1) && s[i][j - 1] == '.') {
              s[i][j - 1] = '#';
            }
          }
        }
      }
      find(n - 1, m - 1);
      int f = 1;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (s[i][j] == 'G' && vis[i][j] == 0) f = 0;
          if (s[i][j] == 'B' && vis[i][j] == 1) f = 0;
        }
      }
      if (f)
        cout << "Yes\n";
      else
        cout << "No\n";
    }
  }
};
int main() {
  DSolveTheMaze solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
