#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<string> a;
vector<int> used;
int check(int y, int x) { return 0 <= y && y < n && 0 <= x && x < m; }
int bfs(int i, int j) {
  queue<pair<int, int>> q;
  q.emplace(i, j);
  used[i * m + j] = 1;
  while (!q.empty()) {
    auto v = q.front();
    q.pop();
    for (int l = -1; l <= 1; ++l) {
      for (int r = -1; r <= 1; ++r) {
        if (l * l + r * r == 1 && check(v.first + l, v.second + r) &&
            !used[(v.first + l) * m + v.second + r] &&
            a[v.first + l][v.second + r] != '#') {
          used[(v.first + l) * m + v.second + r] = 1;
          q.emplace(v.first + l, v.second + r);
        }
      }
    }
  }
  return used[(n - 1) * m + m - 1];
}
void solve() {
  cin >> n >> m;
  used.assign(n * m, false);
  a.resize(n);
  for (auto& i : a) {
    cin >> i;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] != 'B') {
        continue;
      }
      for (int l = -1; l <= 1; ++l) {
        for (int r = -1; r <= 1; ++r) {
          if (l * l + r * r == 1 && check(i + l, j + r)) {
            if (a[i + l][j + r] == '.') {
              a[i + l][j + r] = '#';
            } else if (a[i + l][j + r] == 'G') {
              cout << "No\n";
              return;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == 'G' && !used[i * m + j] && !bfs(i, j)) {
        cout << "No\n";
        return;
      }
    }
  }
  cout << "Yes\n";
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}
