#include <bits/stdc++.h>
const long long mod9 = 1e9 + 7;
const long long maxsize = 2e9 + 1;
const long long mod2 = 1073741824;
const long long INF = 1e18L + 5;
using namespace std;
int n, m;
bool in_or_out(int a, int b) { return (a > 0 && a <= n && b > 0 && b <= m); }
void solve() {
  cin >> n >> m;
  char grid[n + 1][m + 1];
  int G_cntr = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == 'G') G_cntr++;
    }
  }
  bool adj_flag = false;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j] == 'B') {
        grid[i][j] = '#';
        if (i - 1 >= 1 and grid[i - 1][j] != 'G') grid[i - 1][j] = '#';
        if (i + 1 <= n and grid[i + 1][j] != 'G') grid[i + 1][j] = '#';
        if (j + 1 <= m and grid[i][j + 1] != 'G') grid[i][j + 1] = '#';
        if (j - 1 >= 1 and grid[i][j - 1] != 'G')
          grid[i][j - 1] = '#';
        else
          adj_flag = true;
      }
    }
  }
  if (!G_cntr)
    cout << "Yes"
         << "\n";
  else if (adj_flag)
    cout << "No"
         << "\n";
  else if (grid[n][m] == '#')
    cout << "No"
         << "\n";
  else {
    queue<pair<int, int> > q;
    bool visited[n + 1][m + 1];
    memset(visited, false, sizeof(visited));
    q.push({n, m});
    visited[n][m] = true;
    while (!q.empty()) {
      pair<int, int> curr = q.front();
      q.pop();
      int row = curr.first;
      int col = curr.second;
      if (in_or_out(row, col + 1) and !visited[row][col + 1] and
          grid[row][col + 1] != '#') {
        q.push({row, col + 1});
        visited[row][col + 1] = true;
      }
      if (in_or_out(row, col - 1) and !visited[row][col - 1] and
          grid[row][col - 1] != '#') {
        q.push({row, col - 1});
        visited[row][col - 1] = true;
      }
      if (in_or_out(row + 1, col) and !visited[row + 1][col] and
          grid[row + 1][col] != '#') {
        q.push({row + 1, col});
        visited[row + 1][col] = true;
      }
      if (in_or_out(row - 1, col) and !visited[row - 1][col] and
          grid[row - 1][col] != '#') {
        q.push({row - 1, col});
        visited[row - 1][col] = true;
      }
    }
    bool ans = true;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (grid[i][j] == 'G') {
          if (!visited[i][j]) ans = false;
        }
      }
    }
    if (ans) {
      cout << "Yes"
           << "\n";
      return;
    }
    cout << "No"
         << "\n";
    return;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
