#include <bits/stdc++.h>
using namespace std;
char mp[55][55];
bool vis[55][55];
int to[][2] = {0, 1, 0, -1, 1, 0, -1, 0};
int n, m;
bool check(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }
bool bfs() {
  memset(vis, 0, sizeof vis);
  queue<pair<int, int>> que;
  if (mp[n - 1][m - 1] == '.') {
    que.push({n - 1, m - 1});
    vis[n - 1][m - 1] = 1;
  }
  while (!que.empty()) {
    pair<int, int> now = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int dx = now.first + to[i][0];
      int dy = now.second + to[i][1];
      if (check(dx, dy) && !vis[dx][dy] && mp[dx][dy] != '#') {
        que.push({dx, dy});
        vis[dx][dy] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == 'G' && !vis[i][j] || mp[i][j] == 'B' && vis[i][j]) {
        return 0;
      }
    }
  }
  return 1;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> mp[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mp[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int dx = i + to[k][0];
            int dy = j + to[k][1];
            if (check(dx, dy) && mp[dx][dy] == '.') mp[dx][dy] = '#';
          }
        }
      }
    }
    if (bfs())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
