#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<vector<char> > grid(n + 3, vector<char>(m + 3));
    bool tt = true;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        cin >> grid[i][j];
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (grid[i][j] == 'B') {
          if (grid[i - 1][j] == '.') grid[i - 1][j] = '#';
          if (grid[i + 1][j] == '.') grid[i + 1][j] = '#';
          if (grid[i][j - 1] == '.') grid[i][j - 1] = '#';
          if (grid[i][j + 1] == '.') grid[i][j + 1] = '#';
          if (grid[i - 1][j] == 'G' || grid[i + 1][j] == 'G' ||
              grid[i][j - 1] == 'G' || grid[i][j + 1] == 'G')
            tt = false;
        }
      }
    }
    vector<vector<bool> > vis(n + 3, vector<bool>(m + 3, false));
    queue<pair<int, int> > bfs;
    if (grid[n][m] != '#') bfs.push({n, m});
    while (!bfs.empty()) {
      auto to = bfs.front();
      bfs.pop();
      int a = to.first, b = to.second;
      if (vis[a][b]) continue;
      vis[a][b] = true;
      if (!vis[a - 1][b] && (grid[a - 1][b] == 'G' || grid[a - 1][b] == 'B' ||
                             grid[a - 1][b] == '.'))
        bfs.push({a - 1, b});
      if (!vis[a + 1][b] && (grid[a + 1][b] == 'G' || grid[a + 1][b] == 'B' ||
                             grid[a + 1][b] == '.'))
        bfs.push({a + 1, b});
      if (!vis[a][b - 1] && (grid[a][b - 1] == 'G' || grid[a][b - 1] == 'B' ||
                             grid[a][b - 1] == '.'))
        bfs.push({a, b - 1});
      if (!vis[a][b + 1] && (grid[a][b + 1] == 'G' || grid[a][b + 1] == 'B' ||
                             grid[a][b + 1] == '.'))
        bfs.push({a, b + 1});
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (vis[i][j] && grid[i][j] == 'B') tt = false;
        if (!vis[i][j] && grid[i][j] == 'G') tt = false;
      }
    }
    if (tt)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
