#include <bits/stdc++.h>
using namespace std;
int x[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
int n, m;
int visited[100][100];
string s[100];
void dfs(int a, int b) {
  if (visited[a][b]) return;
  if (s[a][b] == '.' || s[a][b] == 'G') visited[a][b] = 1;
  if (a + 1 <= n - 1 && s[a + 1][b] == '.' ||
      a + 1 <= n - 1 && s[a + 1][b] == 'G')
    dfs(a + 1, b);
  if (a - 1 >= 0 && s[a - 1][b] == '.' || a - 1 >= 0 && s[a - 1][b] == 'G')
    dfs(a - 1, b);
  if (b + 1 <= m - 1 && s[a][b + 1] == '.' ||
      b + 1 <= m - 1 && s[a][b + 1] == 'G')
    dfs(a, b + 1);
  if (b - 1 >= 0 && s[a][b - 1] == '.' || b - 1 >= 0 && s[a][b - 1] == 'G')
    dfs(a, b - 1);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    vector<pair<int, int>> v;
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            if (i + x[k][0] >= 0 && j + x[k][1] >= 0 && i + x[k][0] <= n - 1 &&
                j + x[k][1] <= m - 1 && s[i + x[k][0]][j + x[k][1]] == '.') {
              s[i + x[k][0]][j + x[k][1]] = '#';
            }
          }
        } else if (s[i][j] == 'G') {
          v.push_back(make_pair(i, j));
        }
      }
    }
    int flag = 1;
    for (int i = 0; i < v.size(); i++) {
      visited[n][m];
      memset(visited, 0, sizeof(visited));
      int a = v[i].first, b = v[i].second;
      dfs(a, b);
      if (!visited[n - 1][m - 1]) {
        flag = 0;
        break;
      }
    }
    if (!flag)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}
