#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<bool>> vis;
vector<vector<char>> grid;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool valid(int x, int y) {
  return 0 <= x && x <= n - 1 && 0 <= y && y <= m - 1;
}
void block(int x, int y) {
  if (valid(x, y) && grid[x][y] == '.') {
    grid[x][y] = '#';
  }
}
void ff(int x, int y) {
  if (!valid(x, y) || grid[x][y] == '#') return;
  if (vis[x][y]) return;
  vis[x][y] = 1;
  for (int k = 0; k < 4; k++) {
    ff(x + dx[k], y + dy[k]);
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    grid.assign(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> grid[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (grid[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int x = i + dx[k];
            int y = j + dy[k];
            block(x, y);
          }
        }
      }
    }
    bool ans = true;
    vis.assign(n, vector<bool>(m, 0));
    ff(n - 1, m - 1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (grid[i][j] == 'B') {
          ans &= !vis[i][j];
        }
        if (grid[i][j] == 'G') {
          ans &= vis[i][j];
        }
      }
    }
    cout << (ans ? "Yes\n" : "No\n");
  }
}
