#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    char grid[n + 5][m + 5];
    vector<pair<int, int>> bad;
    int good = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> grid[i][j];
        if (grid[i][j] == 'B')
          bad.push_back({i, j});
        else if (grid[i][j] == 'G')
          good++;
      }
    }
    for (auto& it : bad) {
      int i = it.first, j = it.second;
      if (i > 0 && grid[i - 1][j] != 'G' && grid[i - 1][j] != 'B')
        grid[i - 1][j] = '#';
      if (j > 0 && grid[i][j - 1] != 'G' && grid[i][j - 1] != 'B')
        grid[i][j - 1] = '#';
      if (i < n - 1 && grid[i + 1][j] != 'G' && grid[i + 1][j] != 'B')
        grid[i + 1][j] = '#';
      if (j < m - 1 && grid[i][j + 1] != 'G' && grid[i][j + 1] != 'B')
        grid[i][j + 1] = '#';
    }
    int cnt = 0;
    bool ok = (grid[n - 1][m - 1] != 'B');
    queue<pair<int, int>> q;
    bool vis[n + 5][m + 5];
    memset(vis, 0, sizeof vis);
    if (grid[n - 1][m - 1] != 'B' && grid[n - 1][m - 1] != '#')
      q.push({n - 1, m - 1});
    while (!q.empty() && ok) {
      int i = q.front().first, j = q.front().second;
      q.pop();
      if (!vis[i][j]) {
        vis[i][j] = 1;
        if (grid[i][j] == 'G') cnt++;
        if (grid[i][j] == 'B') {
          ok = 0;
          break;
        }
        if (i > 0 && grid[i - 1][j] != '#' && !vis[i - 1][j])
          q.push({i - 1, j});
        if (j > 0 && grid[i][j - 1] != '#' && !vis[i][j - 1])
          q.push({i, j - 1});
        if (i < n - 1 && grid[i + 1][j] != '#' && !vis[i + 1][j])
          q.push({i + 1, j});
        if (j < m - 1 && grid[i][j + 1] != '#' && !vis[i][j + 1])
          q.push({i, j + 1});
      }
    }
    if (ok && cnt == good)
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
  }
  return 0;
}
