#include <bits/stdc++.h>
using namespace std;
const int mx[4] = {1, 0, -1, 0};
const int my[4] = {0, 1, 0, -1};
int n, m;
bool check(const int &x, const int &y) {
  return x >= 0 && x < n && y >= 0 && y < m;
}
bool solve() {
  cin >> n >> m;
  int cnt = 0;
  vector<vector<char>> a(n, vector<char>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      cnt += (a[i][j] == 'G');
    }
  }
  if (!cnt) return true;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] != 'B') continue;
      for (int move = 0; move < 4; ++move) {
        int x = i + mx[move];
        int y = j + my[move];
        if (check(x, y)) {
          if (a[x][y] == 'G')
            return false;
          else if (a[x][y] == '.')
            a[x][y] = '#';
        }
      }
    }
  }
  if (a[n - 1][m - 1] == '#') return false;
  vector<vector<bool>> used(n, vector<bool>(m));
  used[n - 1][m - 1] = true;
  queue<pair<int, int>> q;
  q.emplace(n - 1, m - 1);
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    for (int move = 0; move < 4; ++move) {
      int nx = x + mx[move];
      int ny = y + my[move];
      if (check(nx, ny) && !used[nx][ny] && a[nx][ny] != '#') {
        used[nx][ny] = true;
        q.emplace(nx, ny);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == 'G' && !used[i][j]) return false;
    }
  }
  return true;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(15);
  int T;
  cin >> T;
  while (T-- > 0) {
    cout << (solve() ? "Yes\n" : "No\n");
  }
  return 0;
}
