#include <bits/stdc++.h>
using namespace std;
bool vis[55][55];
char arr[55][55];
void dfs(int i, int j, int n, int m) {
  vis[i][j] = true;
  if (i + 1 < n) {
    if (!vis[i + 1][j] && arr[i + 1][j] != '#') dfs(i + 1, j, n, m);
  }
  if (i - 1 >= 0) {
    if (!vis[i - 1][j] && arr[i - 1][j] != '#') dfs(i - 1, j, n, m);
  }
  if (j + 1 < m) {
    if (!vis[i][j + 1] && arr[i][j + 1] != '#') dfs(i, j + 1, n, m);
  }
  if (j - 1 >= 0) {
    if (!vis[i][j - 1] && arr[i][j - 1] != '#') dfs(i, j - 1, n, m);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1, n, m, ans, r, cnt, c, flag;
  cin >> t;
  while (t--) {
    memset(vis, false, sizeof(vis));
    cin >> n >> m;
    ans = cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> arr[i][j];
        if (arr[i][j] == 'G') cnt++;
      }
    }
    if (cnt == 0 || arr[n - 1][m - 1] == 'B') {
      if (arr[n - 1][m - 1] == 'B')
        cout << "No"
             << "\n";
      else
        cout << "Yes"
             << "\n";
    } else {
      flag = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (arr[i][j] == 'B') {
            if (i + 1 < n && arr[i + 1][j] == '.') arr[i + 1][j] = '#';
            if (i - 1 >= 0 && arr[i - 1][j] == '.') arr[i - 1][j] = '#';
            if (j - 1 >= 0 && arr[i][j - 1] == '.') arr[i][j - 1] = '#';
            if (j + 1 < m && arr[i][j + 1] == '.') arr[i][j + 1] = '#';
          } else if (arr[i][j] == 'G') {
            if (i + 1 < n && arr[i + 1][j] == 'B') {
              flag = 1;
              break;
            }
            if (i - 1 >= 0 && arr[i - 1][j] == 'B') {
              flag = 1;
              break;
            }
            if (j - 1 >= 0 && arr[i][j - 1] == 'B') {
              flag = 1;
              break;
            }
            if (j + 1 < m && arr[i][j + 1] == 'B') {
              flag = 1;
              break;
            }
          }
        }
        if (flag == 1) break;
      }
      if (flag == 1)
        cout << "No"
             << "\n";
      else {
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < m; j++) {
            if (arr[i][j] == 'B') arr[i][j] = '#';
          }
        }
        if (arr[n - 1][m - 1] == '#')
          cout << "No"
               << "\n";
        else {
          dfs(n - 1, m - 1, n, m);
          for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
              if (arr[i][j] == 'G' && !vis[i][j]) {
                flag = 1;
                break;
              }
            }
            if (flag == 1) break;
          }
          if (flag == 1)
            cout << "No"
                 << "\n";
          else
            cout << "Yes"
                 << "\n";
        }
      }
    }
  }
  return 0;
}
