#include <bits/stdc++.h>
using namespace std;
const long long int maxN = 200005;
long long int n, m;
string s[60];
long long int vis[55][55], dp[55][55];
bool sortbysec(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  return (a.second < b.second);
}
bool sortinrev(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  return a.second != b.second && a.first > b.first;
}
long long int check(long long int i, long long int j) {
  if (dp[i][j] != -1) return dp[i][j];
  vis[i][j] = 1;
  if (i == n - 1 && j == m - 1) return 1;
  long long int x = 0;
  if (i + 1 < n && s[i + 1][j] != '#' && vis[i + 1][j] == 0)
    x += check(i + 1, j);
  if (i - 1 >= 0 && s[i - 1][j] != '#' && vis[i - 1][j] == 0)
    x += check(i - 1, j);
  if (j + 1 < m && s[i][j + 1] != '#' && vis[i][j + 1] == 0)
    x += check(i, j + 1);
  if (j - 1 >= 0 && s[i][j - 1] != '#' && vis[i][j - 1] == 0)
    x += check(i, j - 1);
  dp[i][j] = x;
  return x;
}
int32_t main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    long long int b = 0, g = 0;
    cin >> n >> m;
    for (long long int i = 0; i < n; i++) {
      cin >> s[i];
      for (long long int j = 0; j < m; j++) {
        if (s[i][j] == 'G') {
          g++;
        } else if (s[i][j] == 'B') {
          b++;
        }
      }
    }
    if (g == 0) {
      cout << "Yes" << endl;
    } else {
      for (long long int i = 0; i < n; i++) {
        for (long long int j = 0; j < m; j++) {
          if (s[i][j] == 'B') {
            if (i + 1 < n && s[i + 1][j] == '.') s[i + 1][j] = '#';
            if (i - 1 >= 0 && s[i - 1][j] == '.') s[i - 1][j] = '#';
            if (j + 1 < m && s[i][j + 1] == '.') s[i][j + 1] = '#';
            if (j - 1 >= 0 && s[i][j - 1] == '.') s[i][j - 1] = '#';
          }
        }
      }
      long long int flag = 1;
      for (long long int ii = 0; ii < 55; ii++) {
        for (long long int jj = 0; jj < 55; jj++) dp[ii][jj] = -1;
      }
      for (long long int i = 0; i < n && flag != 0; i++) {
        for (long long int j = 0; j < m; j++) {
          for (long long int ii = 0; ii < 55; ii++) {
            for (long long int jj = 0; jj < 55; jj++) vis[ii][jj] = 0;
          }
          if (s[i][j] == 'B') {
            if (check(i, j) != 0) {
              flag = 0;
              break;
            }
          }
          if (s[i][j] == 'G') {
            if (check(i, j) == 0) {
              flag = 0;
              break;
            }
          }
        }
      }
      if (flag)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
}
