#include <bits/stdc++.h>
using namespace std;
char maze[100][100];
int _;
void solve() {
  int n, m, g = 0;
  cin >> n >> m;
  for (int i = 0; i < (100); ++i) {
    for (int j = 0; j < (100); ++j) maze[i][j] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> maze[i][j];
      if (maze[i][j] == 'G') g++;
    }
  }
  bool ok1 = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (maze[i][j] == 'B') {
        if (j - 1 >= 1 && maze[i][j - 1] == 'G') ok1 = false;
        if (i - 1 >= 1 && maze[i - 1][j] == 'G') ok1 = false;
        if (j + 1 <= m && maze[i][j + 1] == 'G') ok1 = false;
        if (i + 1 <= n && maze[i + 1][j] == 'G') ok1 = false;
      }
    }
  }
  if (maze[n - 1][m] == 'B' && g > 0) ok1 = false;
  if (maze[n][m - 1] == 'B' && g > 0) ok1 = false;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (maze[i][j] == 'B') {
        if (j - 1 >= 1 && maze[i][j - 1] == '.') maze[i][j - 1] = '#';
        if (i - 1 >= 1 && maze[i - 1][j] == '.') maze[i - 1][j] = '#';
        if (j + 1 <= m && maze[i][j + 1] == '.') maze[i][j + 1] = '#';
        if (i + 1 <= n && maze[i + 1][j] == '.') maze[i + 1][j] = '#';
      }
    }
  }
  if (maze[n][m] != '#') maze[n][m] = 'p';
  for (int i = n; i > 0; i--) {
    for (int j = m; j > 0; j--) {
      if (maze[i][j] == '.') {
        if (j - 1 >= 1 && maze[i][j - 1] == 'p') maze[i][j] = 'p';
        if (i - 1 >= 1 && maze[i - 1][j] == 'p') maze[i][j] = 'p';
        if (j + 1 <= m && maze[i][j + 1] == 'p') maze[i][j] = 'p';
        if (i + 1 <= n && maze[i + 1][j] == 'p') maze[i][j] = 'p';
      }
    }
  }
  bool ok = true;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int true1 = 0;
      if (maze[i][j] == 'G') {
        if (j - 1 >= 1 && maze[i][j - 1] == 'p' || maze[i][j - 1] == 'G')
          true1++;
        if (i - 1 >= 1 && maze[i - 1][j] == 'p' || maze[i - 1][j] == 'G')
          true1++;
        if (j + 1 <= m && maze[i][j + 1] == 'p' || maze[i][j + 1] == 'G')
          true1++;
        if (i + 1 <= n && maze[i + 1][j] == 'p' || maze[i + 1][j] == 'G')
          true1++;
        if (true1 == 0) {
          ok = false;
          break;
        } else
          cnt++;
      }
    }
  }
  if (_ == 87) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) cout << maze[i][j] << " ";
      cout << "\n";
    }
  }
  if (ok1 && ok && cnt == g)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  cin >> _;
  while (_--) solve();
}
