#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    string s[n];
    for (long long int i = 0; i < n; i++) {
      cin >> s[i];
    }
    long long int go = 0, b = 0;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        if (s[i][j] == 'G') {
          go++;
        } else if (s[i][j] == 'B') {
          b++;
        }
      }
    }
    if (b == 0 && go == 0) {
      cout << "Yes" << '\n';
      continue;
    }
    long long int flag = 0;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < s[i].size(); j++) {
        if (s[i][j] == 'B') {
          if (j) {
            if (s[i][j - 1] == 'G') flag = 1;
            s[i][j - 1] = '#';
          }
          if (i) {
            if (s[i - 1][j] == 'G') flag = 1;
            s[i - 1][j] = '#';
          }
          if (j < m - 1) {
            if (s[i][j + 1] == 'G') flag = 1;
            s[i][j + 1] = '#';
          }
          if (i < n - 1) {
            if (s[i + 1][j] == 'G') flag = 1;
            s[i + 1][j] = '#';
          }
        }
      }
    }
    if (flag) {
      cout << "No" << '\n';
      continue;
    }
    long long int reach = 0;
    bool vis[n][m];
    memset(vis, 0, sizeof(vis));
    queue<pair<long long int, long long int>> q;
    if (s[n - 1][m - 1] != '#') q.push({n - 1, m - 1});
    set<pair<long long int, long long int>> res;
    while (!q.empty()) {
      pair<long long int, long long int> a = q.front();
      q.pop();
      long long int i = a.first;
      long long int j = a.second;
      vis[i][j] = 1;
      if (s[i][j] == 'G') {
        res.insert({i, j});
      }
      if (a.first && s[i - 1][j] != '#' && !vis[i - 1][j]) {
        q.push({i - 1, j});
      }
      if (a.second && s[i][j - 1] != '#' && !vis[i][j - 1]) {
        q.push({i, j - 1});
      }
      if (a.first < n - 1 && s[i + 1][j] != '#' && !vis[i + 1][j]) {
        q.push({i + 1, j});
      }
      if (a.second < m - 1 && s[i][j + 1] != '#' && !vis[i][j + 1]) {
        q.push({i, j + 1});
      }
    }
    if (res.size() != go)
      cout << "No" << '\n';
    else {
      cout << "Yes" << '\n';
    }
  }
}
