#include <bits/stdc++.h>
using namespace std;
const int N = (int)5e4 + 20;
const int mod = (int)1e9 + 7;
char a[100][100];
int n, m, dx[] = {1, 0, 0, -1}, dy[] = {0, -1, 1, 0};
bool check(int x, int y) { return (1 <= x && x <= n && y <= m && y >= 1); }
bool bfs(int A, int B) {
  bool u[n + 1][m + 1];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) u[i][j] = 0;
  queue<pair<int, int> > q;
  q.push(make_pair(A, B));
  while (!q.empty()) {
    pair<int, int> first = q.back();
    u[first.first][first.second] = 1;
    q.pop();
    for (int i = 0; i < 4; ++i) {
      if (check(dx[i] + first.first, dy[i] + first.second) &&
          a[dx[i] + first.first][dy[i] + first.second] != '#' &&
          u[dx[i] + first.first][dy[i] + first.second] == 0) {
        q.push(make_pair(dx[i] + first.first, dy[i] + first.second));
      }
    }
  }
  return u[n][m];
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  vector<pair<int, int> > v;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == 'B') {
        for (int k = 0; k < 4; ++k) {
          if (check(dx[k] + i, dy[k] + j) && a[dx[k] + i][dy[k] + j] == 'G') {
            cout << "No\n";
            return;
          } else {
            a[dx[k] + i][dy[k] + j] = '#';
          }
        }
      }
      if (a[i][j] == 'G') {
        v.push_back(make_pair(i, j));
      }
    }
  }
  for (auto i : v) {
    if (!bfs(i.first, i.second)) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
