#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
int t, n, m;
char grid[55][55];
bool vis[55][55];
void dfs(int x, int y) {
  vis[x][y] = true;
  for (int i = 0; i < 4; i++) {
    int tx = x + dx[i], ty = y + dy[i];
    if (tx >= 0 && tx < n && ty >= 0 && ty < m && !vis[tx][ty] &&
        grid[tx][ty] != '#')
      dfs(tx, ty);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    memset(vis, 0, sizeof vis);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) cin >> grid[i][j];
    bool ok = true;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (grid[i][j] == 'B') {
          bool XX = false;
          for (int k = 0; k < 4; k++) {
            int x = i + dx[k], y = j + dy[k];
            if (x < 0 || x >= n || y < 0 || y >= m || grid[x][y] == 'B')
              continue;
            if (grid[x][y] == 'G') {
              cout << "No" << endl;
              ok = false;
              XX = true;
              break;
            }
            grid[x][y] = '#';
          }
          if (XX) break;
        }
    if (!ok) continue;
    bool flag = true;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (grid[i][j] == 'G' && !vis[i][j]) {
          dfs(i, j);
          if (!vis[n - 1][m - 1]) {
            flag = false;
            break;
          }
        }
    cout << (flag ? "Yes" : "No") << endl;
  }
  return 0;
}
