#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    vector<int> dy{-1, 0, 1, 0};
    vector<int> dx{0, 1, 0, -1};
    int d = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (a[i][j] == 'B') {
          for (int k = 0; k < 4; ++k) {
            int p = i + dy[k];
            int q = j + dx[k];
            if (p >= 0 && p < n) {
              if (q >= 0 && q < m) {
                if (a[p][q] == '.') {
                  a[p][q] = '#';
                } else if (a[p][q] == 'G') {
                  cout << "no" << endl;
                  d = 1;
                  break;
                }
              }
            }
          }
        }
      }
    }
    if (d) {
      continue;
    }
    queue<pair<int, int>> q;
    vector<vector<int>> v(n, vector<int>(m));
    if (a[n - 1][m - 1] != '#') {
      q.emplace(n - 1, m - 1);
    }
    v[n - 1][m - 1] = true;
    while (!q.empty()) {
      auto c = q.front();
      q.pop();
      auto y = c.first, x = c.second;
      for (int k = 0; k < 4; ++k) {
        int s = y + dy[k];
        int t = x + dx[k];
        if (s >= 0 && s < n) {
          if (t >= 0 && t < m) {
            if (!v[s][t] && a[s][t] != '#') {
              v[s][t] = 1;
              q.emplace(s, t);
            }
          }
        }
      }
    }
    bool w = true;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (a[i][j] == 'G' && !v[i][j]) {
          w = false;
          break;
        }
      }
    }
    cout << (w ? "yes" : "no") << endl;
  }
  return 0;
}
