#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
long long n, m;
char grid[55][55];
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
long long reach[55][55];
bool check(long long x, long long y) {
  return (x >= 0 && x < n && y >= 0 && y < m);
}
void modify() {
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (grid[i][j] == 'B') {
        for (long long k = 0; k < 4; k++) {
          long long xx = i + dx[k];
          long long yy = j + dy[k];
          if (check(xx, yy) && grid[xx][yy] == '.') grid[xx][yy] = '#';
        }
      }
      reach[i][j] = -1;
    }
  }
}
long long dfs(long long x, long long y, long long parx, long long pary) {
  if (reach[x][y] != -1) return reach[x][y];
  if (x == n - 1 && y == m - 1) {
    if (grid[x][y] != '#') {
      reach[x][y] = 1;
      return 1;
    } else {
      reach[x][y] = 0;
      return 0;
    }
  }
  if (grid[x][y] == 'B' || grid[x][y] == '#') {
    reach[x][y] = 0;
    return 0;
  }
  long long ans = 0;
  for (long long i = 0; i < 4; i++) {
    long long xx = x + dx[i];
    long long yy = y + dy[i];
    if (check(xx, yy) && !(xx == parx && yy == pary)) {
      long long c = dfs(xx, yy, x, y);
      ans = ans | c;
    }
  }
  reach[x][y] = ans;
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) cin >> grid[i][j];
    }
    modify();
    long long flag = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (grid[i][j] == 'G' && reach[i][j] == -1) {
          dfs(i, j, i, j);
        }
        if (grid[i][j] == 'G' && reach[i][j] == 0) {
          flag = 1;
          break;
        } else if (grid[i][j] == 'B' || grid[i][j] == '#')
          reach[i][j] = 0;
      }
      if (flag) break;
    }
    if (flag) {
      cout << "No"
           << "\n";
    } else
      cout << "Yes"
           << "\n";
  }
  return 0;
}
