#include <bits/stdc++.h>
using namespace std;
bool valid(int i, int j, int n, int m) {
  return i >= 0 && i < n && j >= 0 && j < m;
}
void solve() {
  int n, m;
  int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
  cin >> n >> m;
  char a[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'B') {
        for (int p = 0; p < 4; p++) {
          if (valid(i + dir[p][0], j + dir[p][1], n, m) &&
              a[i + dir[p][0]][j + dir[p][1]] == '.')
            a[i + dir[p][0]][j + dir[p][1]] = '#';
        }
      }
    }
  }
  bool visited[n][m];
  memset(visited, false, sizeof(visited));
  queue<pair<int, int> > q;
  if (a[n - 1][m - 1] == '.') {
    q.push(make_pair(n - 1, m - 1));
    visited[n - 1][m - 1] = true;
  }
  while (!q.empty()) {
    pair<int, int> temp = q.front();
    q.pop();
    for (int p = 0; p < 4; p++) {
      int x = temp.first + dir[p][0];
      int y = temp.second + dir[p][1];
      if (valid(x, y, n, m)) {
        if (!visited[x][y] && a[x][y] != '#') {
          q.push(make_pair(x, y));
          visited[x][y] = true;
        }
      }
    }
  }
  bool ans = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'G' && visited[i][j] != true) {
        ans = false;
        break;
      } else if (a[i][j] == 'B' && visited[i][j] != false) {
        ans = false;
        break;
      }
    }
  }
  cout << (ans ? "Yes" : "No");
}
int main() {
  int t, c = 0;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
}
