#include <bits/stdc++.h>
using namespace std;
const int col = 50;
const int row = 50;
void near(char arr[row][col], int vis[row][col], int r, int c, queue<int> &q1,
          queue<int> &q2, int n, int m) {
  int dr[] = {-1, 1, 0, 0};
  int dc[] = {0, 0, 1, -1};
  for (int i = 0; i < 4; i++) {
    int rr = r + dr[i];
    int rc = c + dc[i];
    if (rr < 0 || rc < 0) continue;
    if (rr >= n || rc >= m) continue;
    if (vis[rr][rc] == 1) continue;
    if (arr[rr][rc] == '#') continue;
    q1.push(rr);
    q2.push(rc);
    vis[rr][rc] = 1;
  }
}
bool solve(char arr[row][col], int s, int ss, int n, int m) {
  queue<int> q1, q2;
  int vis[col][row] = {0};
  vis[s][ss] = 1;
  q1.push(s);
  q2.push(ss);
  while (!q1.empty()) {
    int k = q1.front();
    int kk = q2.front();
    if (k == n - 1 && kk == m - 1) return true;
    near(arr, vis, k, kk, q1, q2, n, m);
    q1.pop();
    q2.pop();
  }
  return false;
}
int main() {
  int t;
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    int n, m, i, j, cnt = 0;
    cin >> n >> m;
    char k;
    char arr[col][row];
    vector<pair<int, int> > v;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cin >> k;
        arr[i][j] = k;
        if (k == 'G') {
          cnt++;
          v.push_back({i, j});
        }
      }
    }
    int ans = 1;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (arr[i][j] == 'B') {
          if (i + 1 < n && arr[i + 1][j] == '.') arr[i + 1][j] = '#';
          if (j + 1 < m && arr[i][j + 1] == '.') arr[i][j + 1] = '#';
          if (i + 1 < n && arr[i + 1][j] == 'G') {
            ans = 0;
          }
          if (j + 1 < m && arr[i][j + 1] == 'G') {
            ans = 0;
          }
        }
      }
    }
    if (ans == 0)
      cout << "No" << endl;
    else if (arr[n - 1][m - 1] == 'B')
      cout << "No" << endl;
    else {
      int cc = 1;
      for (auto itr = v.begin(); itr != v.end(); itr++) {
        if (solve(arr, itr->first, itr->second, n, m) == false) {
          cc = 0;
          break;
        }
      }
      if (cc == 1)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
}
