#include <bits/stdc++.h>
using namespace std;
template <class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
void setmax(T& a, T b) {
  a = max(a, b);
};
template <typename T>
void setmin(T& a, T b) {
  a = min(a, b);
};
template <typename T>
bool in(T lo, T v, T hi) {
  return lo <= v && v <= hi;
};
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<char>> b(n);
  int good = 0, bad = 0;
  for (int i = 0; i < n; i++) {
    string second;
    cin >> second;
    for (int j = 0; j < m; j++) {
      b[i].push_back(second[j]);
      if (b[i][j] == 'G') good++;
      if (b[i][j] == 'B') bad++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i][j] == 'B') {
        for (int d = 0; d < 4; d++) {
          int ni = i + dx[d];
          int nj = j + dy[d];
          if (0 <= ni && ni < n && 0 <= nj && nj < m && b[ni][nj] == '.') {
            b[ni][nj] = '#';
          }
        }
      }
    }
  }
  vector<vector<int>> vis(n, vector<int>(m, 0));
  queue<pair<int, int>> bfs;
  int saved = 0;
  int escaped = 0;
  if (b[n - 1][m - 1] != '#') {
    bfs.push({n - 1, m - 1});
    vis[n - 1][m - 1] = 1;
  }
  while (bfs.size()) {
    pair<int, int> x = bfs.front();
    bfs.pop();
    if (b[x.first][x.second] == 'G') saved++;
    if (b[x.first][x.second] == 'B') escaped++;
    for (int d = 0; d < 4; d++) {
      int nx = x.first + dx[d];
      int ny = x.second + dy[d];
      if (0 <= nx && nx < n && 0 <= ny && ny < m && b[nx][ny] != '#' &&
          !vis[nx][ny]) {
        vis[nx][ny] = 1;
        bfs.push({nx, ny});
      }
    }
  }
  if (saved == good && escaped == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
