#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int n, m, countG, countB;
char a[55][55];
bool vs[55][55];
bool inside(int x, int y) { return (x >= 1 && x <= m && y >= 1 && y <= n); }
bool check() {
  if (a[m][n] != '.') return false;
  memset(vs, false, sizeof(vs));
  int cntG = 0, cntB = 0;
  queue<pair<int, int> > st;
  st.push({m, n});
  while (!st.empty()) {
    int x = st.front().first;
    int y = st.front().second;
    st.pop();
    vs[x][y] = true;
    for (int i = 0; i < 4; ++i) {
      int tmpx = x + dx[i];
      int tmpy = y + dy[i];
      if (inside(tmpx, tmpy) && a[tmpx][tmpy] != '#' &&
          vs[tmpx][tmpy] == false) {
        st.push({tmpx, tmpy});
        if (a[tmpx][tmpy] == 'G') ++cntG;
        if (a[tmpx][tmpy] == 'B') ++cntB;
        vs[tmpx][tmpy] = true;
      }
    }
  }
  return (cntG == countG && cntB == 0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int test;
  cin >> test;
  while (test--) {
    countG = 0;
    countB = 0;
    cin >> m >> n;
    for (int i = 1; i <= m; ++i)
      for (int j = 1; j <= n; ++j) {
        cin >> a[i][j];
        if (a[i][j] == 'G') ++countG;
        if (a[i][j] == 'B') ++countB;
      }
    if (countG == 0) {
      cout << "Yes\n";
      continue;
    }
    bool res = true;
    for (int i = 1; i <= m; ++i)
      for (int j = 1; j <= n; ++j)
        if (a[i][j] == 'B') {
          for (int k = 0; k < 4; ++k) {
            int x = i + dx[k];
            int y = j + dy[k];
            if (inside(x, y) && a[x][y] == '.') a[x][y] = '#';
            if (inside(x, y)) {
              if (a[x][y] == 'G') res = false;
              if (a[x][y] == '.') a[x][y] = '#';
            }
          }
        }
    if (res == false) {
      cout << "No\n";
      continue;
    }
    if (check() == true)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
