#include <bits/stdc++.h>
using namespace std;
char arr[50][50];
bool visited[50][50];
int good_found = 0;
int n, m;
void dfs(int c_r, int c_c) {
  if (c_r < 0 || c_c < 0 || c_r >= n || c_c >= m || arr[c_r][c_c] == '#' ||
      arr[c_r][c_c] == 'B' || visited[c_r][c_c] == true) {
    return;
  }
  if (arr[c_r][c_c] == 'G') {
    good_found++;
  }
  visited[c_r][c_c] = true;
  dfs(c_r - 1, c_c);
  dfs(c_r + 1, c_c);
  dfs(c_r, c_c - 1);
  dfs(c_r, c_c + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    good_found = 0;
    cin >> n >> m;
    int total_good_boys = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> arr[i][j];
        if (arr[i][j] == 'G') {
          total_good_boys++;
        }
      }
    }
    bool possible = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (arr[i][j] == 'B') {
          if (i - 1 >= 0) {
            if (arr[i - 1][j] == 'G') {
              possible = false;
              break;
            }
            if (arr[i - 1][j] == '.') {
              arr[i - 1][j] = '#';
            }
          }
          if (i + 1 < n) {
            if (arr[i + 1][j] == 'G') {
              possible = false;
              break;
            }
            if (arr[i + 1][j] == '.') {
              arr[i + 1][j] = '#';
            }
          }
          if (j - 1 >= 0) {
            if (arr[i][j - 1] == 'G') {
              possible = false;
              break;
            }
            if (arr[i][j - 1] == '.') {
              arr[i][j - 1] = '#';
            }
          }
          if (j + 1 < m) {
            if (arr[i][j + 1] == 'G') {
              possible = false;
              break;
            }
            if (arr[i][j + 1] == '.') {
              arr[i][j + 1] = '#';
            }
          }
        }
      }
      if (possible == false) {
        break;
      }
    }
    if (possible == false) {
      cout << "No\n";
      continue;
    }
    memset(visited, 0, sizeof(visited));
    dfs(n - 1, m - 1);
    if (total_good_boys != good_found) {
      possible = false;
    }
    if (possible == false) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  }
  return 0;
}
