#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
int n, m;
int good = 0, bad = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
char grid[55][55];
bool valid(int dx, int dy) {
  return (1 <= dx && dx <= n && 1 <= dy && dy <= m && grid[dx][dy] != '#');
}
void dfs(int x, int y, bool visited[55][55]) {
  if (visited[x][y]) return;
  visited[x][y] = true;
  if (grid[x][y] == 'B') bad++;
  if (grid[x][y] == 'G') good--;
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (valid(xx, yy)) dfs(xx, yy, visited);
  }
}
void print() {
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < m + 1; j++) {
      cout << grid[i][j] << " ";
    }
    cout << endl;
  }
}
int main() {
  int testCases;
  cin >> testCases;
  while (testCases--) {
    good = 0;
    bad = 0;
    vector<pair<int, int>> badppl;
    bool visited[55][55] = {false};
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        cin >> grid[i][j];
        if (grid[i][j] == 'G') good++;
        if (grid[i][j] == 'B') badppl.emplace_back(i, j);
      }
    for (auto &khayb : badppl) {
      int i, j;
      tie(i, j) = khayb;
      for (int k = 0; k < 4; k++) {
        int xx = i + dx[k];
        int yy = j + dy[k];
        if (!valid(xx, yy)) continue;
        if (grid[xx][yy] == '.') grid[xx][yy] = '#';
      }
    }
    if (grid[n][m] != '#') dfs(n, m, visited);
    if (good == 0 && bad == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
