#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    char a[n + 2][m + 2];
    int vis[n + 1][m + 1];
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cin >> a[i][j], vis[i][j] = -1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (a[i][j] != 'B') continue;
        if (i - 1 >= 1 and a[i - 1][j] == '.') a[i - 1][j] = '#';
        if (i + 1 <= n and a[i + 1][j] == '.') a[i + 1][j] = '#';
        if (j + 1 <= m and a[i][j + 1] == '.') a[i][j + 1] = '#';
        if (j - 1 >= 1 and a[i][j - 1] == '.') a[i][j - 1] = '#';
      }
    }
    queue<pair<int, int> > q;
    if (a[n][m] != '#') {
      q.push({n, m});
      vis[n][m] = 1;
    }
    while (!q.empty()) {
      int i = q.front().first, j = q.front().second;
      q.pop();
      if (i - 1 >= 1 and a[i - 1][j] != '#' and vis[i - 1][j] == -1)
        vis[i - 1][j] = 1, q.push({i - 1, j});
      if (i + 1 <= n and a[i + 1][j] != '#' and vis[i + 1][j] == -1)
        vis[i + 1][j] = 1, q.push({i + 1, j});
      if (j + 1 <= m and a[i][j + 1] != '#' and vis[i][j + 1] == -1)
        vis[i][j + 1] = 1, q.push({i, j + 1});
      if (j - 1 >= 1 and a[i][j - 1] != '#' and vis[i][j - 1] == -1)
        vis[i][j - 1] = 1, q.push({i, j - 1});
    }
    string ans = "Yes";
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        if (a[i][j] == 'G' and vis[i][j] != 1) ans = "No";
        if (a[i][j] == 'B' and vis[i][j] == 1) ans = "No";
      }
    cout << ans << endl;
  }
}
