#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
int mx[] = {-1, 0, 1, 0};
int my[] = {0, 1, 0, -1};
bool check(pair<int, int> node, const vector<vector<char>>& grid) {
  for (int i = 0; i < 4; i++) {
    int nx = mx[i] + node.first;
    int ny = my[i] + node.second;
    if (grid[nx][ny] == 'B') return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(15) << fixed;
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<char> vect(m + 2, '#');
    vector<vector<char>> grid(n + 2, vect);
    vector<bool> row(m + 2, false);
    vector<vector<bool>> goods(n + 2, row);
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        cin >> grid[i][j];
        if (grid[i][j] == 'G') {
          goods[i][j] = true;
          cnt++;
        }
      }
    if (grid[n][m] == 'B' || (!check({n, m}, grid) && cnt)) {
      cout << "No\n";
      continue;
    }
    vector<vector<char>> bfs = grid;
    queue<pair<int, int>> q;
    q.push({n, m});
    while (!q.empty()) {
      pair<int, int> node = q.front();
      q.pop();
      for (int i = 0; i < 4; i++) {
        int nx = mx[i] + node.first;
        int ny = my[i] + node.second;
        if (bfs[nx][ny] != '#' && check({nx, ny}, grid)) {
          q.push({nx, ny});
          bfs[nx][ny] = '#';
          cnt -= goods[nx][ny];
          goods[nx][ny] = false;
        }
      }
    }
    cout << (!cnt ? "Yes\n" : "No\n");
  }
}
