#include <bits/stdc++.h>
using namespace std;
char a[55][55];
int n, m;
int dir[2][4] = {{0, 0, 1, -1}, {1, -1, 0, 0}};
vector<pair<int, int> > G, B, dian;
bool vis[55][55];
int biao[55][55];
void bfs(int x, int y) {
  queue<pair<int, int> > q;
  memset(vis, 0, sizeof vis);
  q.push(make_pair(x, y));
  vis[x][y] = 1;
  while (!q.empty()) {
    pair<int, int> tt = q.front();
    q.pop();
    int xx = tt.first, yy = tt.second;
    if ((0) <= (3))
      for (register int i = (0); i <= (3); i++) {
        int nx = xx + dir[0][i], ny = yy + dir[1][i];
        if (!vis[nx][ny] && nx >= 1 && nx <= n && ny >= 1 && ny <= m &&
            a[nx][ny] != '#') {
          q.push(make_pair(nx, ny));
          vis[nx][ny] = 1;
        }
      }
  }
}
bool f(int x) {
  bfs(n, m);
  if (x == 0) {
    if ((0) <= (G.size() - 1))
      for (register int i = (0); i <= (G.size() - 1); i++) {
        pair<int, int> tt = G[i];
        int xx = tt.first, yy = tt.second;
        if (!vis[xx][yy]) return false;
      }
    return true;
  } else {
    if ((0) <= (B.size() - 1))
      for (register int i = (0); i <= (B.size() - 1); i++) {
        pair<int, int> tt = B[i];
        int xx = tt.first, yy = tt.second;
        if (vis[xx][yy]) return false;
      }
    return true;
  }
}
void solve() {
  cin >> n >> m;
  string s;
  G.clear();
  B.clear();
  dian.clear();
  if ((1) <= (n))
    for (register int i = (1); i <= (n); i++) {
      cin >> s;
      if ((1) <= (m))
        for (register int j = (1); j <= (m); j++) {
          a[i][j] = s[j - 1];
          if (a[i][j] == 'G') {
            G.push_back(make_pair(i, j));
          } else if (a[i][j] == 'B') {
            B.push_back(make_pair(i, j));
          } else if (a[i][j] == '.') {
            dian.push_back(make_pair(i, j));
          }
        }
    }
  if (G.size() == 0 || B.size() == 0) {
    cout << "Yes"
         << "\n";
    return;
  }
  if (!f(0)) {
    cout << "No"
         << "\n";
    return;
  }
  if ((0) <= (dian.size() - 1))
    for (register int i = (0); i <= (dian.size() - 1); i++) {
      pair<int, int> tt = dian[i];
      int xx = tt.first, yy = tt.second;
      if (vis[xx][yy]) {
        a[xx][yy] = '#';
        if (!f(0)) a[xx][yy] = '.';
      }
    }
  if (f(1))
    cout << "Yes"
         << "\n";
  else
    cout << "No"
         << "\n";
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
