#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
using namespace std;
vector<vector<char>> visited;
vector<string> v;
int n, m;
void dfs(int x, int y) {
  visited[x][y] = 1;
  if (x > 0) {
    if (!visited[x - 1][y] && (v[x - 1][y] == '.' || v[x - 1][y] == 'G'))
      dfs(x - 1, y);
  }
  if (y > 0) {
    if (!visited[x][y - 1] && (v[x][y - 1] == '.' || v[x][y - 1] == 'G'))
      dfs(x, y - 1);
  }
  if (x < n - 1) {
    if (!visited[x + 1][y] && (v[x + 1][y] == '.' || v[x + 1][y] == 'G'))
      dfs(x + 1, y);
  }
  if (y < m - 1) {
    if (!visited[x][y + 1] && (v[x][y + 1] == '.' || v[x][y + 1] == 'G'))
      dfs(x, y + 1);
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  int q;
  cin >> q;
  while (q--) {
    cin >> n >> m;
    v.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    bool flag = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (v[i][j] == 'B') {
          if (i > 0) {
            if (v[i - 1][j] == '.')
              v[i - 1][j] = '#';
            else if (v[i - 1][j] == 'G')
              flag = 0;
          }
          if (j > 0) {
            if (v[i][j - 1] == '.')
              v[i][j - 1] = '#';
            else if (v[i][j - 1] == 'G')
              flag = 0;
          }
          if (i < n - 1) {
            if (v[i + 1][j] == '.')
              v[i + 1][j] = '#';
            else if (v[i + 1][j] == 'G')
              flag = 0;
          }
          if (j < m - 1) {
            if (v[i][j + 1] == '.')
              v[i][j + 1] = '#';
            else if (v[i][j + 1] == 'G')
              flag = 0;
          }
        }
      }
    }
    visited.clear();
    visited.resize(n, vector<char>(m, 0));
    dfs(n - 1, m - 1);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (v[i][j] == 'G') cnt++;
        if (v[i][j] == 'G' && visited[i][j] == 0) flag = 0;
      }
    }
    if (v[n - 1][m - 1] == 'B') flag = 0;
    if (v[n - 1][m - 1] == '#' && cnt) flag = 0;
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
