#include <bits/stdc++.h>
using namespace std;
int cansel_sync = (ios::sync_with_stdio(0), cin.tie(0), 0);
const int N = 210;
int n, m, T;
string s[N];
bool inside(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }
bool good(int x, int y) { return s[x][y] == '.' || s[x][y] == 'G'; }
int dn[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
queue<pair<int, int>> q;
signed main() {
  cin >> T;
  while (T--) {
    cin >> n >> m;
    for (int i = (0), _ = (n); i < _; i++) cin >> s[i];
    int ans = true;
    for (int x = (0), _ = (n); x < _; x++)
      for (int y = (0), _ = (m); y < _; y++)
        if (s[x][y] == 'B') {
          for (int k = (0), _ = (4); k < _; k++) {
            int px = x + dn[k][0];
            int py = y + dn[k][1];
            if (inside(px, py)) {
              if (s[px][py] == 'G') ans = false;
              if (s[px][py] == '.') s[px][py] = '#';
            }
          }
        }
    if (s[n - 1][m - 1] == 'B') ans = false;
    if (!good(n - 1, m - 1)) {
      q.push({n - 1, m - 1});
      while (!q.empty()) {
        int x = q.front().first, y = q.front().second;
        q.pop();
        for (int k = (0), _ = (4); k < _; k++) {
          int px = x + dn[k][0];
          int py = y + dn[k][1];
          if (inside(px, py) && good(px, py)) {
            s[px][py] = 'o';
            q.push({px, py});
          }
        }
      }
    }
    for (int i = (0), _ = (n); i < _; i++)
      for (int j = (0), _ = (m); j < _; j++)
        if (s[i][j] == 'G') ans = false;
    cout << (ans ? "Yes" : "No") << endl;
  }
  return 0;
}
