#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t, n, m;
  cin >> t;
  string ans[2] = {"No\n", "Yes\n"};
  while (t--) {
    cin >> n >> m;
    int cant = 0;
    vector<string> data(n);
    for (auto &x : data) {
      cin >> x;
      cant += count(x.begin(), x.end(), 'G');
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (data[i][j] == 'B') {
          if (i > 0 && data[i - 1][j] == '.') data[i - 1][j] = '#';
          if (j > 0 && data[i][j - 1] == '.') data[i][j - 1] = '#';
          if (i + 1 < n && data[i + 1][j] == '.') data[i + 1][j] = '#';
          if (j + 1 < m && data[i][j + 1] == '.') data[i][j + 1] = '#';
        }
      }
    }
    queue<pair<int, int>> q;
    if (data[n - 1][m - 1] != '#') q.push({n - 1, m - 1});
    for (; !q.empty(); q.pop()) {
      int i = q.front().first;
      int j = q.front().second;
      if (data[i][j] == 'B') {
        cant = 1;
        break;
      }
      cant -= (data[i][j] == 'G');
      if (data[i][j] != '#' && data[i][j] != 'a') {
        if (i > 0 && data[i - 1][j] != 'a') q.push({i - 1, j});
        if (j > 0 && data[i][j - 1] != 'a') q.push({i, j - 1});
        if (i + 1 < n && data[i + 1][j] != 'a') q.push({i + 1, j});
        if (j + 1 < m && data[i][j + 1] != 'a') q.push({i, j + 1});
      }
      data[i][j] = 'a';
    }
    cout << ans[cant == 0];
  }
  return 0;
}
